Ejemplo n.º 1
0
        protected virtual void SendKeyDown(short b, bool specialKey)
        {
            if (KeysHeld.Contains(b))
            {
                throw new InputDeviceException(string.Format("Cannot press the key {0} as its already pressed", b));
            }
            KeysHeld.Add(b);
            var keyUpDown = KeyboardWin32.GetSpecialKeyCode(specialKey, KeyboardInput.KeyUpDown.KEYEVENTF_KEYDOWN);

            KeyboardWin32.SendInput(KeyboardWin32.GetInputFor(b, keyUpDown));
        }
Ejemplo n.º 2
0
        protected virtual void SendKeyUp(short b, bool specialKey)
        {
            if (!KeysHeld.Contains(b))
            {
                throw new InputDeviceException(string.Format("Cannot unpress the key {0}, it has not been pressed", b));
            }
            KeysHeld.Remove(b);
            var keyUpDown = KeyboardWin32.GetSpecialKeyCode(specialKey, KeyboardInput.KeyUpDown.KEYEVENTF_KEYUP);

            KeyboardWin32.SendInput(KeyboardWin32.GetInputFor(b, keyUpDown));
        }