Exemple #1
0
 private void KeysPress(InputBuilder builder, IEnumerable <Win32Constants.VirtualKeys> keyCodes)
 {
     if (keyCodes == null)
     {
         return;
     }
     foreach (Win32Constants.VirtualKeys key in keyCodes)
     {
         builder.AddKeyPress(key);
     }
 }
Exemple #2
0
 private void ModifiersDown(InputBuilder builder, IEnumerable <Win32Constants.VirtualKeys> modifierKeyCodes)
 {
     if (modifierKeyCodes == null)
     {
         return;
     }
     foreach (Win32Constants.VirtualKeys key in modifierKeyCodes)
     {
         builder.AddKeyDown(key);
     }
 }
Exemple #3
0
 public IKeyboardSimulator TextEntry(string text)
 {
     if (text.Length > UInt32.MaxValue / 2)
     {
         throw new ArgumentException(
                   string.Format("The text parameter is too long. It must be less than {0} characters.",
                                 UInt32.MaxValue / 2), "text");
     }
     Win32Types.INPUT[] inputList = new InputBuilder().AddCharacters(text).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
Exemple #4
0
        public IKeyboardSimulator ModifiedKeyStroke(
            IEnumerable <Win32Constants.VirtualKeys> modifierKeyCodes, IEnumerable <Win32Constants.VirtualKeys> keyCodes)
        {
            var builder = new InputBuilder();

            Win32Constants.VirtualKeys[] virtualKeyss = modifierKeyCodes.ToArray();
            ModifiersDown(builder, virtualKeyss);
            KeysPress(builder, keyCodes);
            ModifiersUp(builder, virtualKeyss);

            SendSimulatedInput(builder.ToArray());
            return(this);
        }
Exemple #5
0
        private void ModifiersUp(InputBuilder builder, IEnumerable <Win32Constants.VirtualKeys> modifierKeyCodes)
        {
            if (modifierKeyCodes == null)
            {
                return;
            }

            var stack = new Stack <Win32Constants.VirtualKeys>(modifierKeyCodes);

            while (stack.Count > 0)
            {
                builder.AddKeyUp(stack.Pop());
            }
        }
Exemple #6
0
 public IMouseSimulator LeftButtonUp()
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddMouseButtonUp(MouseButton.LeftButton).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
Exemple #7
0
 public IMouseSimulator XButtonDoubleClick(int buttonId)
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddMouseXButtonDoubleClick(buttonId).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
Exemple #8
0
 public IKeyboardSimulator KeyPress(Win32Constants.VirtualKeys keyCode)
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddKeyPress(keyCode).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
Exemple #9
0
 public IKeyboardSimulator TextEntry(char character)
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddCharacter(character).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }