Hello.
How do I get the top left coordinates of a GUI without the window's titlebar, relative to the monitor's Screen?
here is what I mean, I use the mouse to point out which coordinates I want:
AHK's Window Spy gives the position X:1115 and Y:627
and here it gives the position X:1115 Y:652
it is this position I want to get with some way. Is there a native variable or command which gives it? or some other way?
How to get the screen position of a GUI without the titlebar?
Re: How to get the screen position of a GUI without the titlebar?
Use SysGet to get the height of the window caption/title bar (SM_CYCAPTION) and the border around the window, which is different depending on whether it is re-sizable (SM_CYSIZEFRAME) or not (SM_CYFIXEDFRAME). You can make your Gui re-sizable if you use the +Resize option in your initial Gui statement. Run the code at the bottom. It should show:
...which is a total of 23+3=26 for your GuiWindow. If you made it resizable, it would be 23+8=31.
Code:
Code: Select all
Caption height: 23
Height of fixed window border: 3
Height of resizable window border: 8
Code:
Code: Select all
SysGet, SM_CYCAPTION, 4
SysGet, SM_CYFIXEDFRAME, 8
SysGet, SM_CYSIZEFRAME, 33
MsgBox, % "Caption height: " SM_CYCAPTION "`n"
. "Height of fixed window border: " SM_CYFIXEDFRAME "`n"
. "Height of resizable window border: " SM_CYSIZEFRAME
-
- Posts: 4353
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to get the screen position of a GUI without the titlebar?
Such calculation doesn't always give the correct result. To get the coordinates of the client area GetWindowInfo function is used:
Code: Select all
Gui, +hwndhGui
Gui, Show, w300 h200
VarSetCapacity(WINDOWINFO, 60)
NumPut(60, WINDOWINFO)
DllCall("GetWindowInfo", "Ptr", hGui, "Ptr", &WINDOWINFO)
MsgBox, % "ClientX: " . NumGet(WINDOWINFO, 20, "Int") . "`n"
. "ClientY: " . NumGet(WINDOWINFO, 24, "Int")
Who is online
Users browsing this forum: Bing [Bot], Google [Bot], Tvlao and 167 guests