private static IntPtr SetHook(InterceptKeys.LowLevelKeyboardProc proc) { using (Process currentProcess = Process.GetCurrentProcess()) { using (ProcessModule mainModule = currentProcess.MainModule) return(InterceptKeys.SetWindowsHookEx(13, proc, InterceptKeys.GetModuleHandle(mainModule.ModuleName), 0U)); } }
private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { if (nCode >= 0 && wParam == (IntPtr)256) { int num = Marshal.ReadInt32(lParam); if (InterceptKeys.KeyPress != null) { InterceptKeys.KeyPress((object)null, new EventArgs <int>(num)); } } return(InterceptKeys.CallNextHookEx(InterceptKeys._hookID, nCode, wParam, lParam)); }
public static void Dispose() { InterceptKeys.UnhookWindowsHookEx(InterceptKeys._hookID); }
public static void Init() { InterceptKeys._hookID = InterceptKeys.SetHook(InterceptKeys._proc); }