Locate X & Y coordinates of another programs window

Just starting out? Need help? Post your questions and find answers here.
Waussie
User
User
Posts: 24
Joined: Fri Nov 11, 2005 12:14 pm

Locate X & Y coordinates of another programs window

Post 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?
Currently coding the unbelievable WFS program...
You'll know it, when it gets released...
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: Locate X & Y coordinates of another programs window

Post 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
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Waussie
User
User
Posts: 24
Joined: Fri Nov 11, 2005 12:14 pm

Re: Locate X & Y coordinates of another programs window

Post 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.
Currently coding the unbelievable WFS program...
You'll know it, when it gets released...
PureLust
Enthusiast
Enthusiast
Posts: 478
Joined: Mon Apr 16, 2007 3:57 am
Location: Germany, NRW

Re: Locate X & Y coordinates of another programs window

Post 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.)
[Dynamic-Dialogs] - create complex GUIs the easy way
[DeFlicker] - easily deflicker your resizeable Windows
[WinFX] - Window Effects (incl. 'click-through' Window)
Post Reply