Beispiel #1
0
        public KeyboardHook(ICollection <Key> keys)
        {
            keyboardProc = HookCallback;
            hookId       = SetHook(keyboardProc);

            SelectedKeys = new HashSet <Key>(keys);
        }
Beispiel #2
0
 private IntPtr SetHook(LowLevelKeyboardProc proc)
 {
     using (Process curProcess = Process.GetCurrentProcess())
         using (ProcessModule curModule = curProcess.MainModule)
         {
             return(NativeMethods.SetWindowsHookEx(
                        idHook: WH_KEYBOARD_LL,
                        lpfn: proc,
                        hMod: NativeMethods.GetModuleHandle(curModule.ModuleName),
                        dwThreadId: 0));
         }
 }