I provide 2 scripts, the first, the OnMessage script receives WM_LBUTTONDOWN from a GUI and 0x5555 messages, the second, the WndProc script only receives the 0x5555 messages.
Code: Select all
;OnMessage
;based on an example at:
;https://autohotkey.com/docs/commands/OnMessage.htm
Gui, Add, Text,, Click anywhere in this window.
Gui, Show
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x5555, "MsgMonitor")
return
WM_LBUTTONDOWN(wParam, lParam)
{
ToolTip, % A_Now " " A_MSec
}
MsgMonitor(wParam, lParam, msg)
{
ToolTip, % A_Now " " A_MSec
}
GuiClose:
ExitApp
Code: Select all
;OnMessage replaced with a custom WndProc
pWndProc := RegisterCallback("MyWndProc", "")
;GWL_WNDPROC := -4
vSfx := (A_PtrSize=8) ? "Ptr" : ""
pWndProcOld := DllCall("SetWindowLong" vSfx, Ptr,A_ScriptHwnd, Int,-4, Ptr,pWndProc, Ptr)
Gui, Add, Text,, Click anywhere in this window.
Gui, Show
return
MyWndProc(hWnd, uMsg, wParam, lParam)
{
global pWndProcOld
if (uMsg = 0x201) ;WM_LBUTTONDOWN
ToolTip, % A_Now " " A_MSec
if (uMsg = 0x5555)
ToolTip, % A_Now " " A_MSec
return DllCall("CallWindowProc", Ptr,pWndProcOld, Ptr,hWnd, UInt,uMsg, UPtr,wParam, Ptr,lParam)
}
GuiClose:
ExitApp
w::
DetectHiddenWindows, On
PostMessage, 0x5555,,,, % "ahk_id " A_ScriptHwnd
return