protected override HookHandle Subscribe() { return(HookHandle.Create( HookType.AppMouse, HookProcedure, IntPtr.Zero, ThreadNativeMethods.GetCurrentThreadId())); }
private static HookResult HookApp(int hookId, Callback callback) { _appHookProc = (code, param, lParam) => HookProcedure(code, param, lParam, callback); var hookHandle = HookNativeMethods.SetWindowsHookEx( hookId, _appHookProc, IntPtr.Zero, ThreadNativeMethods.GetCurrentThreadId()); if (hookHandle.IsInvalid) { ThrowLastUnmanagedErrorAsException(); } return(new HookResult(hookHandle, _appHookProc)); }