private void KeysPress(InputBuilder builder, IEnumerable <Win32Constants.VirtualKeys> keyCodes)
 {
     if (keyCodes == null)
     {
         return;
     }
     foreach (Win32Constants.VirtualKeys key in keyCodes)
     {
         builder.AddKeyPress(key);
     }
 }
 public IKeyboardSimulator TextEntry(string text)
 {
     if (text.Length > UInt32.MaxValue / 2)
     {
         throw new ArgumentException(
                   $"The text parameter is too long. It must be less than {UInt32.MaxValue / 2} characters.", nameof(text));
     }
     Win32Types.INPUT[] inputList = new InputBuilder().AddCharacters(text).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
 private void ModifiersDown(InputBuilder builder, IEnumerable <Win32Constants.VirtualKeys> modifierKeyCodes)
 {
     if (modifierKeyCodes == null)
     {
         return;
     }
     foreach (Win32Constants.VirtualKeys key in modifierKeyCodes)
     {
         builder.AddKeyDown(key);
     }
 }
        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);
        }
        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());
            }
        }
 public IKeyboardSimulator KeyPress(Win32Constants.VirtualKeys keyCode)
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddKeyPress(keyCode).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
 public IKeyboardSimulator TextEntry(char character)
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddCharacter(character).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
예제 #8
0
 public IMouseSimulator LeftButtonClick()
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddMouseButtonClick(MouseButton.LeftButton).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }
예제 #9
0
 public IMouseSimulator XButtonDoubleClick(int buttonId)
 {
     Win32Types.INPUT[] inputList = new InputBuilder().AddMouseXButtonDoubleClick(buttonId).ToArray();
     SendSimulatedInput(inputList);
     return(this);
 }