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()); } }
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) }); }
static void SendKeyboardInput(KEYBDINPUT ki) { NativeKeyboardMouse.SendInput(new[] { ToInput(ki) }); }
public static void EnterCharacters(string text) { var inputs = text.SelectMany(ToInputsForUnicode).ToArray(); NativeKeyboardMouse.SendInput(inputs); }
public static void EnterCharacter(char c) { NativeKeyboardMouse.SendInput(ToInputsForUnicode(c)); }
static void SendMouseInput(MOUSEINPUT mi) { NativeKeyboardMouse.SendInput(new[] { ToInput(mi) }); }