Hopefully this will work for you. Cheers.
Code: Select all
q:: ;post click
CoordMode, Pixel, Screen
;testing on MS Paint (Windows XP version), looking for aqua colour:
;draw some aqua pixels, then change the primary colour,
;watch the aqua pixels get replaced as you trigger the hotkey
PixelSearch, vPosX, vPosY, 1, 1, 1920, 1080, 0x00FFFF, 0, Fast RGB
;if !hWnd := DllCall("WindowFromPoint", Int,vPosX, Int,vPosY, Ptr)
if !hWnd := DllCall("WindowFromPoint", UInt64,(vPosX&0xFFFFFFFF)|(vPosY<<32), Ptr)
return
VarSetCapacity(POINT, 8, 0)
NumPut(vPosX, POINT, 0, "Int"), NumPut(vPosY, POINT, 4, "Int")
DllCall("user32\ScreenToClient", Ptr,hWnd, Ptr,&POINT)
vPosX := NumGet(POINT, 0, "Int"), vPosY := NumGet(POINT, 4, "Int")
;ToolTip, % vPosX " " vPosY
;test that the coordinates are correct by using WM_MOUSEMOVE:
;PostMessage, 0x200, 0, % vPosX&0xFFFF|vPosY<<16,, % "ahk_id " hWnd ;WM_MOUSEMOVE := 0x200
PostMessage, 0x201, 0, % vPosX&0xFFFF|vPosY<<16,, % "ahk_id " hWnd ;WM_LBUTTONDOWN := 0x201
PostMessage, 0x202, 0, % vPosX&0xFFFF|vPosY<<16,, % "ahk_id " hWnd ;WM_LBUTTONUP := 0x202
return