Code: Select all
ControlClick2(X, Y, WinTitle="", WinText="", ExcludeTitle="", ExcludeText="")
{
hwnd:=ControlFromPoint(X, Y, WinTitle, WinText, cX, cY
, ExcludeTitle, ExcludeText)
PostMessage, 0x201, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDOWN
PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
PostMessage, 0x203, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONDBLCLCK
PostMessage, 0x202, 0, cX&0xFFFF | cY<<16,, ahk_id %hwnd% ; WM_LBUTTONUP
}
ControlFromPoint(X, Y, WinTitle="", WinText="", ByRef cX="", ByRef cY="", ExcludeTitle="", ExcludeText="")
{
if !(hwnd := WinExist(WinTitle, WinText, ExcludeTitle, ExcludeText))
return false
VarSetCapacity(pt,8)
; Convert coords -- relative to top-left of window -> relative to client area.
VarSetCapacity(wi,60), NumPut(60,wi)
DllCall("GetWindowInfo","uint",hwnd,"uint",&wi)
NumPut(X + (w:=NumGet(wi,4,"int")) - (cw:=NumGet(wi,20,"int")), pt,0)
NumPut(Y + (h:=NumGet(wi,8,"int")) - (ch:=NumGet(wi,24,"int")), pt,4)
Loop {
child := DllCall("ChildWindowFromPointEx","uint",hwnd,"int64",NumGet(pt,0,"int64"),"uint",0x5)
if !child or child=hwnd
break
; Make pt relative to child client area.
DllCall("MapWindowPoints","uint",hwnd,"uint",child,"uint",&pt,"uint",1)
hwnd := child
}
cX := NumGet(pt,0,"int")
cY := NumGet(pt,4,"int")
return hwnd
}
But still the same problem, it looks like something is happening with the window when I point my mouse cursor on it(nothing notable), but it doesn't click anywhere.