/// <summary> /// Initializes hooks /// </summary> private void SetUpHooks() { if (RibbonDesigner.Current == null) { if (_mouseHook == null) { _mouseHook = new GlobalHook(GlobalHook.HookTypes.Mouse); _mouseHook.MouseWheel += new MouseEventHandler(_mouseHook_MouseWheel); _mouseHook.MouseDown += new MouseEventHandler(_mouseHook_MouseDown); } if (_keyboardHook == null) { _keyboardHook = new GlobalHook(GlobalHook.HookTypes.Keyboard); _keyboardHook.KeyDown += new KeyEventHandler(_keyboardHook_KeyDown); } } }
/// <summary> /// Initializes hooks /// </summary> private void SetUpHooks() { if (!(Site != null && Site.DesignMode)) { // _mouseHook = new GlobalHook(GlobalHook.HookTypes.Mouse); // _mouseHook.MouseWheel += new MouseEventHandler(_mouseHook_MouseWheel); // _mouseHook.MouseDown += new MouseEventHandler(_mouseHook_MouseDown); _keyboardHook = new GlobalHook(GlobalHook.HookTypes.Keyboard); _keyboardHook.KeyDown += new KeyEventHandler(_keyboardHook_KeyDown); } }
private void DisposeHooks() { if (_mouseHook != null) { _mouseHook.MouseWheel -= new MouseEventHandler(_mouseHook_MouseWheel); _mouseHook.MouseDown -= new MouseEventHandler(_mouseHook_MouseDown); _mouseHook.Dispose(); _mouseHook = null; } if (_keyboardHook != null) { _keyboardHook.KeyDown -= new KeyEventHandler(_keyboardHook_KeyDown); _keyboardHook.Dispose(); _keyboardHook = null; } }
internal static extern int SetWindowsHookEx(int idHook, GlobalHook.HookProcCallBack lpfn, IntPtr hInstance, int threadId);