Пример #1
0
        private IntPtr SetHook(KeyboardProcedure proc)
        {
            Process       currentProcess = Process.GetCurrentProcess();
            ProcessModule currentModule  = currentProcess.MainModule;

            return(SetWindowsHookEx(WH_KEYBOARD_LL, proc,
                                    GetModuleHandle(currentModule.ModuleName), 0));
        }
Пример #2
0
 private void UnhookKeyboard()
 {
     if (keyboardHookId != IntPtr.Zero)
     {
         UnhookWindowsHookEx(keyboardHookId);
         keyboardHookId           = IntPtr.Zero;
         CurrentKeyboardProcedure = null;
     }
 }
Пример #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);
         }
     }
 }
Пример #4
0
 private static extern IntPtr SetWindowsHookEx(int idHook,
                                               KeyboardProcedure lpfn, IntPtr hMod, uint dwThreadId);
Пример #5
0
 public static IntPtr SetWindowsHookEx(int idHook, KeyboardProcedure lpfn, IntPtr hMod, uint dwThreadId)
 {
     return(SetWindowsHookExNative(idHook, lpfn, hMod, dwThreadId));
 }
Пример #6
0
 private static extern IntPtr SetWindowsHookEx(int idHook,
     KeyboardProcedure lpfn, IntPtr hMod, uint dwThreadId);
Пример #7
0
 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);
     }
 }