One more question here tonight: OnMessage(0x200, "OnMouseMove"), from what I can see, monitors the GUI to see if the cursor is ontop of it *constantly*. So while the cursor is ontop, it continues to see that it is indeed ontop (kind of like a loop, until the cursor leaves)
I was looking to see if there's an OnMessage to monitor the GUI to see when the cursor enters the GUI, but only upon entry and then terminate the monitoring?
So in other words, when the cursor eventually enters the GUI, it should recognize the cursor's entrance, and then stop monitoring.
Hope this makes sense. I checked this page for all possible messages, and even tried a few, but none worked:
https://www.autohotkey.com/docs/misc/Se ... geList.htm
OnMessage(0x200, "OnMouseMove")
-
- Posts: 844
- Joined: 21 Dec 2015, 02:34
Re: OnMessage(0x200, "OnMouseMove")
Hello, there is a message called WM_MOUSELEAVE. Edit: fixed incorrect struct size. I didn't get it to work on 64 bit though
Code: Select all
OnMessage(0x200, "OnMouseMove")
gui, +hwndguiId
; This doesn't work on 64 bit
/*
typedef struct tagTRACKMOUSEEVENT {
DWORD cbSize;
DWORD dwFlags;
HWND hwndTrack;
DWORD dwHoverTime;
} TRACKMOUSEEVENT, *LPTRACKMOUSEEVENT;
*/
WM_MOUSELEAVE:=0x2A3
cbSize:=A_PtrSize=4?16:24
TME_LEAVE:=0x00000002
dwFlags:=TME_LEAVE
VarSetCapacity(TRACKMOUSEEVENT, cbSize,0)
NumPut(cbSize, TRACKMOUSEEVENT, 0, "Uint")
NumPut(dwFlags, TRACKMOUSEEVENT, 4, "Uint")
NumPut(guiId, TRACKMOUSEEVENT, 8, "Ptr")
; NumPut(0, TRACKMOUSEEVENT, 8+A_PtrSize, "Uint") ; Not needed
if !DllCall("User32.dll\TrackMouseEvent", "Ptr", &TRACKMOUSEEVENT)
Msgbox fail
else
OnMessage(WM_MOUSELEAVE, "WM_MOUSELEAVE")
gui, show, w200 h200
OnMouseMove(){
global TRACKMOUSEEVENT
OnMessage(0x200, "OnMouseMove", 0)
DllCall("User32.dll\TrackMouseEvent", "Ptr", &TRACKMOUSEEVENT)
ToolTip % "Mouse entered gui @ " A_TickCount,0,0
}
WM_MOUSELEAVE(){
ToolTip, % "Mouse left gui @ " A_TickCount,0,0
OnMessage(0x200, "OnMouseMove")
}
esc::
guiclose:
exitapp
Last edited by Helgef on 23 Jul 2017, 06:58, edited 2 times in total.
Re: OnMessage(0x200, "OnMouseMove")
4 + 4 + 8 + 4 ended up being 24.Helgef wrote:Hello, there is a message called WM_MOUSELEAVE. I didn't get it to work on 64 bit though
Code: Select all
cbSize := A_PtrSize == 8 ? 24 : 16
Re: OnMessage(0x200, "OnMouseMove")
Indeed, sizeof(TRACKMOUSEEVENT); is 24 on 64 bit. Ty, I'll edit the code.
Who is online
Users browsing this forum: No registered users and 199 guests