示例#1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="GlobalKeyboardListener" /> class and installs the keyboard hook.</summary>
        public GlobalKeyboardListener()
        {
            IntPtr hInstance = WinAPI.LoadLibrary("User32");

            _hook  = hookProc;  // don’t remove this or the garbage collector will collect it while the global hook still tries to access it
            _hHook = WinAPI.SetWindowsHookEx(WinAPI.WH_KEYBOARD_LL, _hook, IntPtr.Zero, 0);
        }
示例#2
0
        /// <summary>
        /// Occurs when one of the hooked keys is pressed and released
        /// </summary>
        //public event KeyEventHandler KeyPressed;

        /// <summary>
        /// Initializes a new instance of the <see cref="globalKeyboardHook"/> class and installs the keyboard hook.
        /// </summary>
        public GlobalKeyboardHook()
        {
            keyboardHookProc = HookCallback;
            Hook();
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="GlobalKeyboardListener" /> class and installs the keyboard hook.</summary>
 public GlobalKeyboardListener()
 {
     IntPtr hInstance = WinAPI.LoadLibrary("User32");
     _hook = hookProc;   // don’t remove this or the garbage collector will collect it while the global hook still tries to access it
     _hHook = WinAPI.SetWindowsHookEx(WinAPI.WH_KEYBOARD_LL, _hook, IntPtr.Zero, 0);
 }
示例#4
0
文件: WinAPI.cs 项目: biorpg/RT.Util
 public static extern IntPtr SetWindowsHookEx(int idHook, WinAPI.KeyboardHookProc callback, IntPtr hInstance, uint threadId);