Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            _proc   = HookCallback;
            _hookID = SetHook(_proc);
        }
 private IntPtr SetHook(User32.LowLevelKeyboardProc proc)
 {
     using (Process currentProcess = Process.GetCurrentProcess())
         using (ProcessModule currentModule = currentProcess.MainModule)
         {
             return(User32.SetWindowsHookEx(User32.WH_KEYBOARD_LL, proc, User32.GetModuleHandle(currentModule.ModuleName), 0));
         }
 }
Example #3
0
 private static IntPtr SetKeyboardHook(User32.LowLevelKeyboardProc callbackFunction)
 {
     using (Process curProcess = Process.GetCurrentProcess())
     {
         using (ProcessModule curModule = curProcess.MainModule)
         {
             return(User32.SetWindowsHookEx(
                        User32.WH_KEYBOARD_LL,
                        callbackFunction,
                        Kernel32.GetModuleHandle(curModule.ModuleName),
                        0));
         }
     }
 }
Example #4
0
 private static IntPtr SetHook(User32.LowLevelKeyboardProc proc)
 {
     using Process curProcess      = Process.GetCurrentProcess();
     using ProcessModule curModule = curProcess.MainModule;
     return(User32.SetWindowsHookEx((int)PlatformFlags.WH_KEYBOARD_LL, proc, Kernel32.GetModuleHandle(curModule.ModuleName), 0));
 }
Example #5
0
 public void Start()
 {
     callbackFunction    = OnKeyPressed;
     KeyboardHookPointer = SetKeyboardHook(callbackFunction);
 }