views:

84

answers:

2

Can it be moved by Window Title as well as exe name?

Other info on moving it in another language could be helpful.

Update: some Perl sample can be found in Win32::GuiTest but there seems to be no resize or move functions.

+1  A: 

Here's a way to do it in Ruby using win32-api:

# example.rb
require 'win32/api'
include Win32

FindWindow = API.new('FindWindow', 'PP', 'L', 'user32')
hWnd = FindWindow.call(nil, "firefox")
if (hWnd == 0)
  puts "firefox not found"
  exit 1
end

MoveWindow = API.new('MoveWindow', 'LIIIII', 'I', 'user32')
ret = MoveWindow.call(hWnd, 0, 0, 1024, 768, true)
if (ret == 0)
  puts "MoveWindow failed"
  exit 1
end

puts "success"

This only works if the window is called "firefox" exactly (not case-sensitive from when I tested). Since it is likely to be titled differently (e.g., "Google - Mozilla Firefox"), you'll probably want to use EnumWindows to enumerate through all windows and find the one you're looking for.

Steven