Exemple #1
0
        /// <summary>
        /// HookCallbackAsync procedure that calls accordingly the KeyDown or KeyUp events.
        /// </summary>
        /// <param name="keyEvent">Keyboard event</param>
        /// <param name="vkCode">VKCode</param>
        void KeyboardListener_KeyboardCallbackAsync(InterceptKeys.KeyEvent keyEvent, int vkCode)
        {
            switch (keyEvent)
            {
            // KeyDown events
            case InterceptKeys.KeyEvent.WM_KEYDOWN:
                if (KeyDown != null)
                {
                    KeyDown(this, new RawKeyEventArgs(vkCode, false));
                }
                break;

            case InterceptKeys.KeyEvent.WM_SYSKEYDOWN:
                if (KeyDown != null)
                {
                    KeyDown(this, new RawKeyEventArgs(vkCode, true));
                }
                break;

            // KeyUp events
            case InterceptKeys.KeyEvent.WM_KEYUP:
                if (KeyUp != null)
                {
                    KeyUp(this, new RawKeyEventArgs(vkCode, false));
                }
                break;

            case InterceptKeys.KeyEvent.WM_SYSKEYUP:
                if (KeyUp != null)
                {
                    KeyUp(this, new RawKeyEventArgs(vkCode, true));
                }
                break;
            }
        }
        /// <summary>
        /// HookCallbackAsync procedure that calls accordingly the KeyDown or KeyUp events.
        /// </summary>
        /// <param name="keyEvent">Keyboard event</param>
        /// <param name="vkCode">VKCode</param>
        /// <param name="character">Character as string.</param>
        void KeyboardListener_KeyboardCallbackAsync(InterceptKeys.KeyEvent keyEvent, int vkCode, string character)
        {
            switch (keyEvent)
            {
            // KeyDown events
            case InterceptKeys.KeyEvent.WM_KEYDOWN:
                if (KeyDown != null)
                {
                    _dispatcher.BeginInvoke(new RawKeyEventHandler(KeyDown), this, new RawKeyEventArgs(vkCode, false, character));
                }
                break;

            case InterceptKeys.KeyEvent.WM_SYSKEYDOWN:
                if (KeyDown != null)
                {
                    _dispatcher.BeginInvoke(new RawKeyEventHandler(KeyDown), this, new RawKeyEventArgs(vkCode, true, character));
                }
                break;

            // KeyUp events
            case InterceptKeys.KeyEvent.WM_KEYUP:
                if (KeyUp != null)
                {
                    _dispatcher.BeginInvoke(new RawKeyEventHandler(KeyUp), this, new RawKeyEventArgs(vkCode, false, character));
                }
                break;

            case InterceptKeys.KeyEvent.WM_SYSKEYUP:
                if (KeyUp != null)
                {
                    _dispatcher.BeginInvoke(new RawKeyEventHandler(KeyUp), this, new RawKeyEventArgs(vkCode, true, character));
                }
                break;
            }
        }