internal static IntPtr SetHook(LowLevelKeyboardProc proc)
 {
     using (var curProcess = Process.GetCurrentProcess())
         using (var curModule = curProcess.MainModule)
         {
             return(DllUser32.SetWindowsHookEx(WH_KEYBOARD_LL, proc, DllUser32.GetModuleHandle(curModule.ModuleName), 0));
         }
 }
        private static IntPtr SetHook(LowLevelMouseProc mouseProc)
        {
            var hook = DllUser32.SetWindowsHookEx(WH_MOUSE_LL, mouseProc, DllUser32.GetModuleHandle("user32"), 0);

            if (hook == IntPtr.Zero)
            {
                throw new Win32Exception();
            }

            return(hook);
        }