OnMessage

Additional features for OnMessage function.

OutputVar := OnMessage(MsgNumber , HWND, Function, MaxThreads)
Command  Example: OnMessage 0x999, A_ScriptHwnd, WatchMessages
Function Example: OnMessage(0x999, A_ScriptHwnd, WatchMessages)

Parameters

MsgNumber

The number of the message.

HWND (optional)

The HWND of the window to monitor, use 0 to monitor all windows.

Function (optional)

The function object to call when the message is received. See AutoHotkey v2 docs.

MaxThreads (optional)

See AutoHotkey v2 docs.

Example

OnMessage 0x0201, MyGui.hwnd, LBUTTONDOWN ; register
OnMessage 0x0201, MyGui.hwnd, LBUTTONDOWN, 0 ; delete
OnMessage 0x0201, MyGui.hwnd, , 0 ; same as above, but will delete all registered functions for MsgNumber && HWND combination.