Exemplo n.º 1
0
 private void KeysPress(InputBuilder builder, IEnumerable <VirtualKeyCode> keyCodes)
 {
     if (keyCodes == null)
     {
         return;
     }
     foreach (var key in keyCodes)
     {
         builder.AddKeyPress(key);
     }
 }
Exemplo n.º 2
0
 private void ModifiersDown(InputBuilder builder, IEnumerable <VirtualKeyCode> modifierKeyCodes)
 {
     if (modifierKeyCodes == null)
     {
         return;
     }
     foreach (var key in modifierKeyCodes)
     {
         builder.AddKeyDown(key);
     }
 }
Exemplo n.º 3
0
        public IKeyboardSimulator ModifiedKeyStroke(IEnumerable <VirtualKeyCode> modifierKeyCodes,
                                                    IEnumerable <VirtualKeyCode> keyCodes)
        {
            var builder = new InputBuilder();

            ModifiersDown(builder, modifierKeyCodes);
            KeysPress(builder, keyCodes);
            ModifiersUp(builder, modifierKeyCodes);

            SendSimulatedInput(builder.ToArray());
            return(this);
        }
Exemplo n.º 4
0
        public IKeyboardSimulator TextEntry(string text)
        {
            if (text.Length > uint.MaxValue / 2)
            {
                throw new ArgumentException(
                          string.Format("The text parameter is too long. It must be less than {0} characters.",
                                        uint.MaxValue / 2), "text");
            }
            var inputList = new InputBuilder().AddCharacters(text).ToArray();

            SendSimulatedInput(inputList);
            return(this);
        }
Exemplo n.º 5
0
        private void ModifiersUp(InputBuilder builder, IEnumerable <VirtualKeyCode> modifierKeyCodes)
        {
            if (modifierKeyCodes == null)
            {
                return;
            }

            var stack = new Stack <VirtualKeyCode>(modifierKeyCodes);

            while (stack.Count > 0)
            {
                builder.AddKeyUp(stack.Pop());
            }
        }