Page 1 of 1

Locate X & Y coordinates of another programs window

Posted: Wed Oct 27, 2010 3:01 pm
by Waussie
I'm trying to get my hands on the coordinates of another programs window.
My code sofar does detect the window, but i can't get any coordinates from where it is displayed.
Yes, I use the droopy lib!

handle=0
Repeat
handle=GetHandle("Another program window")
Until handle<>0
hand$=Str(handle)
MessageRequester("HandleName", hand$)

So what do i do next to get coordinates of the window?

Re: Locate X & Y coordinates of another programs window

Posted: Wed Oct 27, 2010 3:10 pm
by gnozal
Here is an example using API :

Code: Select all

hWnd = FindWindow_(#Null, @"Calculator") ; Find Window
If hWnd
  If GetWindowRect_(hWnd, @Coordinates.rect) ; Get coordinates
    Debug "X      = " + Str(Coordinates\left)
    Debug "Y      = " + Str(Coordinates\top)
    Debug "Width  = " + Str(Coordinates\right - Coordinates\left)
    Debug "Height = " + Str(Coordinates\bottom - Coordinates\top)
  EndIf
EndIf

Re: Locate X & Y coordinates of another programs window

Posted: Tue Nov 02, 2010 11:30 am
by Waussie
Is there a way to cycle through all windows?
For an example:
I try to get the handle of any windowtitle called:
"This is my window 1.*"

Where * could be any value, so it wil work for future versions.

Re: Locate X & Y coordinates of another programs window

Posted: Tue Nov 02, 2010 12:07 pm
by PureLust
Waussie wrote:Is there a way to cycle through all windows?
You may have a look at the AllWindows-Browser.pb example in the PB-Code-Archiv.

(I have an improved and much faster version of the linked code on one of my older Backup-Harddrives. So, if you have problems to get the example to work, just shout and I'll see if I can find it.)