Show / Hide Table of Contents

Method WindowsHook.ThreadMouse


Overload

Sets a WH_MOUSE hook for a thread of this process. See API SetWindowsHookEx.

public static WindowsHook ThreadMouse(Func<HookData.ThreadMouse, bool> hookProc, int threadId = 0, bool setNow = true)
Parameters
hookProc  (Func<HookData.ThreadMouse, bool>)

The hook procedure (function that handles hook events). Must return as soon as possible. If returns true, the event is canceled.

note

When the hook procedure returns, the pointer field of the parameter variable becomes invalid and unsafe to use.

threadId  (int)

Native thread id, or 0 for this thread. The thread must belong to this process.

setNow  (bool)

Set hook now. Default true.

Returns
WindowsHook

New WindowsHook object that manages the hook.

Exceptions
AuException

Failed.

Examples

using var hook = WindowsHook.ThreadMouse(x => {
	print.it(x.message, x.m->pt, x.m->hwnd, x.PM_NOREMOVE);
	return false;
});
dialog.show("hook");