Beispiel #1
0
        private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                KeyboardHookStruct keyboardStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
                KeyboardHookArgs   args           = new KeyboardHookArgs();
                args.Key = (Keys)keyboardStruct.vkCode;
                if (wParam == user32.WM_KEYDOWN || wParam == user32.WM_SYSKEYDOWN)
                {
                    OnKeyDown(args);
                }
                else if (wParam == user32.WM_KEYUP || wParam == user32.WM_SYSKEYUP)
                {
                    OnKeyUp(args);
                }
            }

            if (IsCallNextHook)
            {
                return(user32.CallNextHookEx(HookID, nCode, wParam, lParam));
            }
            else
            {
                IsCallNextHook = true;
                return(1);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 触发按钮按下事件
        /// </summary>
        /// <param name="e"></param>
        protected void OnKeyDown(KeyboardHookArgs e)
        {
            EventHandler <KeyboardHookArgs> h = this.KeyDown;

            if (h != null)
            {
                h(this, e);
            }
        }
Beispiel #3
0
        public void KeyboardClick(object sender, KeyboardHookArgs e)
        {
            byte[] keyState = new byte[256];
            user32.GetKeyboardState(keyState);

            if (MatchAndSend(JoystickButtons.None, keyState))
            {
                KeyHook.IsCallNextHook = false;
            }
        }
Beispiel #4
0
        public void KeyboardClick(object sender, KeyboardHookArgs e)
        {
            TextBox textBox = (TextBox)Keyboard.FocusedElement;

            if (textBox == null)
            {
                return;
            }

            KeyStoreInfo keyStore = textBox.DataContext as KeyStoreInfo;

            if (keyStore != null)
            {
                keyStore.SetStoreValue(e.Key);
                //ItemList.Focus();
            }

            FinishInput();
        }
        public void KeyboardClick(object sender, KeyboardHookArgs e)
        {
            TextBox textBox = (TextBox)Keyboard.FocusedElement;
            if (textBox == null)
                return;

            KeyStoreInfo keyStore = textBox.DataContext as KeyStoreInfo;
            if (keyStore != null)
            {
                keyStore.SetStoreValue(e.Key);
                //ItemList.Focus();
            }

            FinishInput();
        }
        public void KeyboardClick(object sender, KeyboardHookArgs e)
        {
            byte[] keyState = new byte[256];
            user32.GetKeyboardState(keyState);

            if (MatchAndSend(JoystickButtons.None, keyState))
            {
                KeyHook.IsCallNextHook = false;
            }
        }
Beispiel #7
0
        private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                KeyboardHookStruct keyboardStruct = (KeyboardHookStruct)Marshal.PtrToStructure(lParam, typeof(KeyboardHookStruct));
                KeyboardHookArgs args = new KeyboardHookArgs();
                args.Key = (Keys)keyboardStruct.vkCode;
                if (wParam == user32.WM_KEYDOWN || wParam == user32.WM_SYSKEYDOWN)
                {
                    OnKeyDown(args);
                }
                else if (wParam == user32.WM_KEYUP || wParam == user32.WM_SYSKEYUP)
                {
                    OnKeyUp(args);
                }

            }

            if (IsCallNextHook)
            {
                return user32.CallNextHookEx(HookID, nCode, wParam, lParam);
            }
            else
            {
                IsCallNextHook = true;
                return 1;
            }
        }
Beispiel #8
0
 /// <summary>
 /// 触发按钮按下事件
 /// </summary>
 /// <param name="e"></param>
 protected void OnKeyDown(KeyboardHookArgs e)
 {
     EventHandler<KeyboardHookArgs> h = this.KeyDown;
     if (h != null) h(this, e);
 }