Пример #1
0
        public void DoAction(KeyActions ka, Key k)
        {
            if (k == Key.None)
            {
                return;
            }
            //Console.WriteLine(k);
            VirtualKeyCode code = (VirtualKeyCode)KeyInterop.VirtualKeyFromKey(k);

            switch (ka)
            {
            case KeyActions.DOWN:
                ks.KeyDown(code);
                break;

            case KeyActions.UP:
                ks.KeyUp(code);
                break;

            case KeyActions.PRESS:
                ks.KeyDown(code);
                ks.KeyUp(code);
                break;
            }
        }
        public void Activate(string key, params string[] modifierNames)
        {
            var modifiers = _mapper.MapKeys(modifierNames);
            var keyCode   = _mapper.MapKey(key);

            if (!keyCode.HasValue)
            {
                Log.Warn($"No mapped key for '{key}'");
                return;
            }

            // IKeyboardSimulator.ModifiedKeyStroke is the standard way to do this, but something about the speed of execution
            // means Elite doesn't always react. Instead, control the sequence of events manually, and add a custom delay.
            foreach (var mod in modifiers)
            {
                _keyboard.KeyDown(mod);
            }
            _keyboard.KeyDown(keyCode.Value);
            Thread.Sleep(KeyDownTime);
            _keyboard.KeyUp(keyCode.Value);
            foreach (var mod in modifiers)
            {
                _keyboard.KeyUp(mod);
            }
        }
Пример #3
0
        public void Keyhift()
        {
            bool down = false, up = false;

            Hook.I().AddKeyHook((Key k) =>
            {
                if (k.ToString().Contains("Shift"))
                {
                    down = true;
                }

                Console.WriteLine("d {0}", k.ToString());
            }, (Key k) =>
            {
                if (k.ToString().Contains("Shift"))
                {
                    up = true;
                }

                Console.WriteLine("u {0}", k.ToString());
            });

            Thread.Sleep(w);
            ks.KeyDown(VirtualKeyCode.SHIFT);
            ks.KeyUp(VirtualKeyCode.SHIFT);
            Assert.IsTrue(down);
            Assert.IsTrue(up);
        }
        private static void CtrlWinKey(VirtualKeyCode virtualKeyCode)
        {
            _keyboardSimulator.KeyDown(VirtualKeyCode.LCONTROL);
            _keyboardSimulator.KeyDown(VirtualKeyCode.LWIN);

            _keyboardSimulator.KeyPress(virtualKeyCode);

            _keyboardSimulator.KeyUp(VirtualKeyCode.LWIN);
            _keyboardSimulator.KeyUp(VirtualKeyCode.LCONTROL);
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        //Minimising performance hit from active buttons
        if (lerpPos != 0)
        {
            //lerpPos 0 = Button unpressed, lerpPos 1 = Button fully pressed
            //Update position of the button
            transform.localPosition = Vector3.Lerp(unpressedPos, pressedPos, lerpPos);


            //Simulate keyboard input if button is pressed enough
            if (lerpPos >= keyPressRange)
            {
                keyboardSim.KeyDown(key);
            }
            else
            {
                keyboardSim.KeyUp(key);
            }

            //If button is not being pressed down, begin releasing button
            if (lerpPos <= previousLerpPos)
            {
                //Button is no longer being pressed
                lerpPos -= Time.deltaTime / resistence;
            }

            //Limit button position alpha to be between 0 and 1, then update the previous position
            lerpPos         = Mathf.Clamp(lerpPos, 0, 1);
            previousLerpPos = lerpPos;
        }
    }
Пример #6
0
 public void SepararItens()
 {
     teclado.KeyDown(VirtualKeyCode.SHIFT);
     mouse.LeftButtonClick();
     teclado.KeyUp(VirtualKeyCode.SHIFT);
     teclado.KeyPress(VirtualKeyCode.VK_1);
     teclado.KeyPress(VirtualKeyCode.RETURN);
 }
Пример #7
0
 public void FireKeyEvent(IKeyboardSimulator a_iks, keyboardPacket a_kp)
 {
     if (a_kp.flags == 0x00)
     {
         a_iks.KeyUp((WindowsInput.Native.VirtualKeyCode)a_kp.vkCode);
     }
     else
     {
         a_iks.KeyDown((WindowsInput.Native.VirtualKeyCode)a_kp.vkCode);
     }
 }
Пример #8
0
        private void BackSpaceButton(State state)
        {
            var isBackDown = state.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Back);

            if (isBackDown && !_wasBackDown)
            {
                _keyboardSimulator.KeyDown(WindowsInput.Native.VirtualKeyCode.BACK);
            }
            if (!isBackDown && _wasBackDown)
            {
                _keyboardSimulator.KeyUp(WindowsInput.Native.VirtualKeyCode.BACK);
            }
            _wasBackDown = isBackDown;
        }
Пример #9
0
 private void IntKeys(int[] aKey)
 {
     foreach (int k in aKey)
     {
         Keys key = (Keys)Math.Abs(k);
         if (k < 0)
         {
             Logger.Log("Sending key up: " + key);
             Keyboard.KeyUp(key.ToVitual());
         }
         else
         {
             Logger.Log("Sending key down: " + key);
             Keyboard.KeyDown(key.ToVitual());
         }
     }
 }
Пример #10
0
        public void Input()
        {
            foreach (var key in keys)
            {
                if (key.IsWait())
                {
                    Thread.Sleep((int)key.WaitMillis);
                }
                else
                {
                    var codes = key.GetVirtualKeyCodes();
                    foreach (var code in codes)
                    {
                        if (code != VirtualKeyCode.VK_5)
                        {
                            keyboard.KeyPress(code);
                        }
                    }
                }
            }

            foreach (var key in keys)
            {
                if (!key.IsWait())
                {
                    var codes = key.GetVirtualKeyCodes();
                    foreach (var code in codes)
                    {
                        if (code != VirtualKeyCode.VK_5)
                        {
                            keyboard.KeyUp(code);
                        }
                    }
                }
            }
        }
Пример #11
0
 public void EndPressing(VirtualKeyCode keyCode = VirtualKeyCode.SPACE) => _keyboard.KeyUp(keyCode);
Пример #12
0
 private async Task SimulateKeyUp(VirtualKeyCode keyCode)
 {
     _simulator.KeyUp(keyCode);
 }
Пример #13
0
 /// <summary>
 ///  Initiates an input into the OS so simulate a key up action.
 /// </summary>
 protected void KeyUp()
 {
     keyboard.KeyUp(KeyCode);
 }