I assume you are asking about Microsoft Windows. This is a very
specific question which is more related to Windows programming and the
Windows API than Ruby programming. But nonetheless:
1. To set the mouse position you need the SetCursorPos function, which
you can access from Ruby like so:
require 'Win32API'
setCursorPos =3D Win32API.new("user32", "SetCursorPos", ['I','I'], 'V')
setCursorPos.Call(100,100)
2. To get the location of a Window whose title you know, do the following:
require 'Win32API'
findWindow =3D Win32API.new("user32", "FindWindow", ['P','P'], 'L')
getClientRect =3D Win32API.new("user32", "GetClientRect", ['P','P'], 'V')
hwnd =3D findWindow.Call(nil, 'name of window here')
lpRect =3D " " * 16 # Four LONGs
getClientRect.Call(hwnd, lpRect)
left, top, right, bottom =3D lpRect.unpack('LLLL')
puts "Left: #{left}, Top: #{top}, Right: #{right}, Bottom: #{bottom}"
Ryan