Page 1 of 1

Get a control position on screen

Posted: 23 Jun 2019, 09:15
by m3user
Is it possible to get a control (for example button) position relative to entire screen? I tried GuiControl Get, Pos but it only gets a position relative to window.

Re: Get a control position on screen

Posted: 23 Jun 2019, 09:29
by swagfag
WinGetPos for the window's screen x, y
the control's screen x, y are then the window's screen x, y + the control's relative x, y

Re: Get a control position on screen

Posted: 23 Jun 2019, 12:26
by m3user
ok, thanks! ;)

Re: Get a control position on screen

Posted: 23 Jun 2019, 14:21
by m3user
Unfortunately I still have issues finding the position:
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=65665

Re: Get a control position on screen  Topic is solved

Posted: 23 Jun 2019, 16:03
by jeeswg
You could get the control's hWnd, and pass that to WinGetPos.

Code: Select all

q:: ;control get screen coordinates
ControlGet, hCtl, Hwnd,, Button1, A
WinGetPos, vWinX, vWinY, vWinW, vWinH, % "ahk_id " hCtl
MsgBox, % Format("x{} y{} w{} h{}", vWinX, vWinY, vWinW, vWinH)
return

Re: Get a control position on screen

Posted: 24 Jun 2019, 11:52
by m3user
Thank you very much!