It would be really great to get the controls name from an X Y position. Being able to do that, the slow WinGet with his loop wouldn't be necessary. Thanks.
Get the control from an X Y position
Started by
shader
, Dec 24 2004 06:31 PM
4 replies to this topic
#1
-
Posted 24 December 2004 - 06:31 PM
Is this possible, I can't find a way to do this?
Thanks.
Thanks.
#3
-
Posted 07 January 2010 - 09:17 AM
Unless you're doing a bazillion checks, there should be no noticeable performance hit from using something like this:
; ; ControlsAtPos() by infogulch ; ; Returns: ; A linefeed-delimited list of control hwnds ; that intersect the given position in a window. ; ; Params: ; WinTitle: the parent window from which to find controls ; fx, fy: the coordinates, relative to the parent, which the controls must overlap ; ; library compatible if named ControlsAtPos.ahk ; ControlsAtPos(WinTitle, fx, fy) { WinGet, list, ControlListHwnd, %WinTitle% loop, parse, list, `n { ControlGetPos, x, y, w, h, , ahk_id %A_LoopField% if (x <= fx && fx <= x+w) && (y <= fy && fy <= y+h) ret .= "`n" A_LoopField ; controls can overlap, so a single position could theoretically ; have more than one control } return SubStr(ret, 2) }
#4
-
Posted 07 January 2010 - 08:53 PM