BarryG wrote: Sat Oct 22, 2022 12:02 pm
WindowFromPoint? No, the mouse won't be over it. Just literally need to know when the window is at that position on the desktop, no matter which other app I'm using at the time.
The function is independent of the mouse position.
You can do it as below.
Code: Select all
;First, check if the existing window is at a specific coordinate.
pt.POINT\x = 1692
pt\y = 697
hwnd = WindowFromPoint_(PeekQ(pt))
If hwnd And GetParent_(hwnd) = 0
GetWindowRect_(hwnd, win.RECT)
If win\left=1692 And win\top=697
;Do something...
EndIf
EndIf
hHook = SetWinEventHook_(#EVENT_SYSTEM_MOVESIZEEND, #EVENT_SYSTEM_MOVESIZEEND, 0, @WinEventProc(), 0, 0, #WINEVENT_OUTOFCONTEXT | #WINEVENT_SKIPOWNPROCESS)
......
Of course, if the windows are overlapped at the position, only the brute-force way is available.
So, use a method that suits your situation.
EDIT:
If you also want to detect the location of a window that is moved automatically (i.e., programmatically), you can do the following
Code: Select all
#EVENT_SYSTEM_MOVESIZESTART = $000A
#EVENT_SYSTEM_MOVESIZEEND = $000B
#EVENT_OBJECT_SHOW = $8002
#EVENT_OBJECT_LOCATIONCHANGE = $800B
#WINEVENT_OUTOFCONTEXT = 0
#WINEVENT_SKIPOWNPROCESS = 2
Procedure WinEventProc(hWinEventHook, event.l, hwnd, idObject.l, idChild.l, idEventThread.l, dwmsEventTime.l)
Static MoveByUser
If event = #EVENT_SYSTEM_MOVESIZESTART
MoveByUser = 1
ProcedureReturn
EndIf
If event = #EVENT_SYSTEM_MOVESIZEEND Or (MoveByUser = 0 And (event = #EVENT_OBJECT_LOCATIONCHANGE Or event = #EVENT_OBJECT_SHOW))
MoveByUser = 0
If GetParent_(hwnd) = 0 And IsWindowVisible_(hwnd)
GetWindowRect_(hwnd, win.RECT)
If win\left=1692 And win\top=697
Debug hwnd
EndIf
EndIf
EndIf
EndProcedure
;First, check if the existing window is at a specific coordinate.
pt.POINT\x = 1692
pt\y = 697
hwnd = WindowFromPoint_(PeekQ(pt))
If hwnd And GetParent_(hwnd) = 0
GetWindowRect_(hwnd, win.RECT)
If win\left=1692 And win\top=697
;Do something...
EndIf
EndIf
hHook = SetWinEventHook_(#EVENT_SYSTEM_MOVESIZESTART, #EVENT_OBJECT_LOCATIONCHANGE, 0, @WinEventProc(), 0, 0, #WINEVENT_OUTOFCONTEXT | #WINEVENT_SKIPOWNPROCESS)
......