예제 #1
0
        public static void StrokeKey(Keys key)
        {
            if ((key & Keys.Modifiers) == Keys.None)
            {
                var ki_down = ToKeyboardInputForKeyDown(key);
                var ki_up   = ToKeyboardInputForKeyUp(key);
                NativeKeyboardMouse.SendInput(new[] { ToInput(ki_down), ToInput(ki_up) });
            }
            else
            {
                var kis = new List <KEYBDINPUT>
                {
                    ToKeyboardInputForKeyDown(key),
                    ToKeyboardInputForKeyUp(key),
                };

                if (key.HasFlag(Keys.Shift))
                {
                    kis.Insert(0, ToKeyboardInputForKeyDown(Keys.ShiftKey));
                    kis.Add(ToKeyboardInputForKeyUp(Keys.ShiftKey));
                }
                if (key.HasFlag(Keys.Control))
                {
                    kis.Insert(0, ToKeyboardInputForKeyDown(Keys.ControlKey));
                    kis.Add(ToKeyboardInputForKeyUp(Keys.ControlKey));
                }
                if (key.HasFlag(Keys.Alt))
                {
                    kis.Insert(0, ToKeyboardInputForKeyDown(Keys.Menu));
                    kis.Add(ToKeyboardInputForKeyUp(Keys.Menu));
                }
                NativeKeyboardMouse.SendInput(kis.Select(ToInput).ToArray());
            }
        }
예제 #2
0
        public static void Click(MouseButtonType button)
        {
            var mi_down = ToMouseInputForButtonDown(button);
            var mi_up   = ToMouseInputForButtonUp(button);

            NativeKeyboardMouse.SendInput(new[] { ToInput(mi_down), ToInput(mi_up) });
        }
예제 #3
0
 static void SendKeyboardInput(KEYBDINPUT ki)
 {
     NativeKeyboardMouse.SendInput(new[] { ToInput(ki) });
 }
예제 #4
0
        public static void EnterCharacters(string text)
        {
            var inputs = text.SelectMany(ToInputsForUnicode).ToArray();

            NativeKeyboardMouse.SendInput(inputs);
        }
예제 #5
0
 public static void EnterCharacter(char c)
 {
     NativeKeyboardMouse.SendInput(ToInputsForUnicode(c));
 }
예제 #6
0
 static void SendMouseInput(MOUSEINPUT mi)
 {
     NativeKeyboardMouse.SendInput(new[] { ToInput(mi) });
 }