private static IntPtr SetHook(NativeWin32.LowLevelKeyboardProc proc) { using (Process curProcess = Process.GetCurrentProcess()) using (ProcessModule curModule = curProcess.MainModule) { return(NativeWin32.SetWindowsHookEx(WH_KEYBOARD_LL, proc, NativeWin32.GetModuleHandle(curModule.ModuleName), 0)); } }