/// <summary> /// Start the keyboard hook. /// </summary> /// <returns>True if no exceptions.</returns> public static bool Enable() { if (Enabled == false) { try { using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) hHook = Hooks.SetWindowsHookEx((int)Hooks.HookType.WH_KEYBOARD_LL, hookproc, Hooks.GetModuleHandle(curModule.ModuleName), 0); Enabled = true; return(true); } catch { Enabled = false; return(false); } } else { return(false); } }
public static bool Enable() { if (!bool_0) { try { using (Process process = Process.GetCurrentProcess()) { using (ProcessModule module = process.MainModule) { intptr_0 = Hooks.SetWindowsHookEx(13, hookProc_0, Hooks.GetModuleHandle(module.ModuleName), 0); } } bool_0 = true; return(true); } catch { bool_0 = false; return(false); } } return(false); }