private IntPtr SetHook(KeyboardProcedure proc)
        {
            Process       currentProcess = Process.GetCurrentProcess();
            ProcessModule currentModule  = currentProcess.MainModule;

            return(SetWindowsHookEx(WH_KEYBOARD_LL, proc,
                                    GetModuleHandle(currentModule.ModuleName), 0));
        }
Example #2
0
 private void UnhookKeyboard()
 {
     if (keyboardHookId != IntPtr.Zero)
     {
         UnhookWindowsHookEx(keyboardHookId);
         keyboardHookId           = IntPtr.Zero;
         CurrentKeyboardProcedure = null;
     }
 }
Example #3
0
 public void HookKeyboard()
 {
     CurrentKeyboardProcedure = HookCallback;
     using (Process currentProcess = Process.GetCurrentProcess())
     {
         using (ProcessModule currentModule = currentProcess.MainModule)
         {
             Debug.Assert(keyboardHookId == IntPtr.Zero);
             keyboardHookId = SetWindowsHookEx(WH_KEYBOARD_LL, CurrentKeyboardProcedure, GetModuleHandle(currentModule.ModuleName), 0);
         }
     }
 }
 private static extern IntPtr SetWindowsHookEx(int idHook,
                                               KeyboardProcedure lpfn, IntPtr hMod, uint dwThreadId);
Example #5
0
 public static IntPtr SetWindowsHookEx(int idHook, KeyboardProcedure lpfn, IntPtr hMod, uint dwThreadId)
 {
     return(SetWindowsHookExNative(idHook, lpfn, hMod, dwThreadId));
 }
 private static extern IntPtr SetWindowsHookEx(int idHook,
     KeyboardProcedure lpfn, IntPtr hMod, uint dwThreadId);
 private IntPtr SetHook(KeyboardProcedure proc)
 {
     using (Process currentProcess = Process.GetCurrentProcess())
     using (ProcessModule currentModule = currentProcess.MainModule)
     {
         return SetWindowsHookEx(WH_KEYBOARD_LL, proc,
             GetModuleHandle(currentModule.ModuleName), 0);
     }
 }