Get a control position on screen Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Get a control position on screen

23 Jun 2019, 09:15

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.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Get a control position on screen

23 Jun 2019, 09:29

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
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Get a control position on screen  Topic is solved

23 Jun 2019, 16:03

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
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
m3user
Posts: 235
Joined: 17 Jan 2014, 18:11

Re: Get a control position on screen

24 Jun 2019, 11:52

Thank you very much!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Rohwedder and 371 guests