public static void StartHook(IntPtr handle) { FindSlideViewWindowHandle(handle); hookProcedure = HookProcedureCallback; hook = Native.SetWindowsHookEx((int)Native.HookType.WH_MOUSE, hookProcedure, 0, Native.GetWindowThreadProcessId(slideViewWindowHandle, 0)); }
public static void CreateHook(IntPtr handle) { _currentSlideViewWindowHandle = FindSlideViewWindowHandle(handle); hookProcedure = HookProcedureCallback; _hookId = Native.SetWindowsHookEx((int)Native.HookType.WH_KEYBOARD, hookProcedure, 0, Native.GetWindowThreadProcessId(_currentSlideViewWindowHandle, 0)); }
public static void Init() { MouseHookProcedure = MouseHookProc; hHook = Native.SetWindowsHookEx(Native.WH_GETMESSAGE, MouseHookProcedure, IntPtr.Zero, AppDomain.GetCurrentThreadId()); if (hHook == 0) { //if we failed, then nothing we can do about it } }
public static void Init() { MouseHookProcedure = new Native.HookProc(MouseHookProc); hHook = Native.SetWindowsHookEx(Native.WH_GETMESSAGE, MouseHookProcedure, IntPtr.Zero, AppDomain.GetCurrentThreadId()); if (hHook == 0) { //if we failed, then nothing we can do about it } }
private void InitHook() { uint id = Native.GetCurrentThreadId(); this.KeyboardProcDelegate = new Native.HookProc(this.KeyboardProc); khook = Native.SetWindowsHookEx(Native.WH_KEYBOARD, this.KeyboardProcDelegate, IntPtr.Zero, id); this.MouseProcDelegate = new Native.HookProc(this.MouseProc); mhook = Native.SetWindowsHookEx(Native.WH_MOUSE, this.MouseProcDelegate, IntPtr.Zero, id); }
public LMouseUpListener() { this.callBack += new Native.HookProc(MouseEvents); using (System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess()) using (System.Diagnostics.ProcessModule module = process.MainModule) { IntPtr hModule = Native.GetModuleHandle(module.ModuleName); _hook = Native.SetWindowsHookEx( (int)Native.HookType.WH_MOUSE_LL, this.callBack, hModule, 0); } }
public LMouseUpListener() { this.CallBack += new Native.HookProc(MouseEvents); using (System.Diagnostics.Process process = System.Diagnostics.Process.GetCurrentProcess()) using (System.Diagnostics.ProcessModule module = process.MainModule) { IntPtr hModule = Native.GetModuleHandle(module.ModuleName); _hook = Native.SetWindowsHookEx( (int)Native.HookType.WH_MOUSE_LL, this.CallBack, hModule, 0); } }
/// <summary> /// Releases all resources used by the current instance of the <see cref="GlobalKeyboardHook" /> class. /// </summary> public void Dispose() { if (Hook != IntPtr.Zero) { Native.UnhookWindowsHookEx(Hook); Hook = IntPtr.Zero; HookProcedure -= KeyboardHookProc; } if (User32Library != IntPtr.Zero) { Native.FreeLibrary(User32Library); User32Library = IntPtr.Zero; } }
/// <summary> /// Initializes a new instance of the <see cref="GlobalKeyboardHook" /> class and starts capturing. /// </summary> public GlobalKeyboardHook() { User32Library = Native.LoadLibrary("user32.dll"); HookProcedure = KeyboardHookProc; Hook = Native.SetWindowsHookEx(13, HookProcedure, User32Library, 0); }