Allows you to simulate global mouse and keyboard events. Features:
Supported OS:
Install-Package H.InputSimulator
new InputSimulator().Keyboard
.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_A)
.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_C)
.ModifiedKeyStroke(VirtualKeyCode.CONTROL, VirtualKeyCode.VK_V);
new InputSimulator().Keyboard
.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_E);
new InputSimulator().Keyboard
.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
.Sleep(1000)
.TextEntry("notepad")
.Sleep(1000)
.KeyPress(VirtualKeyCode.RETURN)
.Sleep(1000)
.TextEntry("These are your orders if you choose to accept them...")
.TextEntry("This message will self destruct in 5 seconds.")
.Sleep(5000)
.ModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.F4)
.KeyPress(VirtualKeyCode.VK_N);
new InputSimulator().Keyboard
.ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
.Sleep(1000)
.TextEntry("mspaint")
.Sleep(1000)
.KeyPress(VirtualKeyCode.RETURN)
.Sleep(1000)
.Mouse
.LeftButtonDown()
.MoveMouseToPositionOnVirtualDesktop(65535 / 2, 65535 / 2)
.LeftButtonUp();
Please think of the library as a high-level wrapper over Win32 SendInput
call.
Unfortunately, this is a limitation of the API itself, according to this documentation:
The easiest way to get around this is to run your application as an administrator.
Priority place for bugs: https://github.com/HavenDV/H.InputSimulator/issues
Priority place for ideas and general questions: https://github.com/HavenDV/H.InputSimulator/discussions
I also have a Discord support channel:
https://discord.gg/g8u2t9dKgE