Language: EN


Emulate keyboard or mouse in .NET with Input Simulator

H.InputSimulator is a .NET library that allows you to simulate keyboard or mouse input under the Windows operating system.

In general, emulating input devices should be the last option for automation. But, in many cases, input automation is a very useful tool for integrating with other programs.

This library is based on the library, which in turn is a fork of the well-known However, InputSimulator is not compatible with .NET Core, and InputSimulatorPlus is currently unmaintained.

InputSimulator provides functionalities for input simulation, such as simulating key presses, modified key presses, or direct text input. Additionally, it can also simulate mouse movement, click simulation, or mouse wheel scrolling.

How to use InputSimulator

We can add the library to a .NET project easily, through the corresponding Nuget package.

Install-Package H.InputSimulator

The library provides the InputSimulator which has methods to emulate keyboard and mouse input in a “fluent” syntax.

For example, if we want to simulate the pressing of the Enter key, we can do so with the following code:

using H.InputSimulator;

// ...

InputSimulator inputSimulator = new InputSimulator();

This code will simulate entering the phone number “555-555-5555” in the text field, then press the Tab key to move to the next text field, and finally, write “12345” in the second text field and press the Enter key to submit the form.


inputSimulator.Keyboard.TextEntry("my text");

Here are a couple of more complex examples, taken from the library’s documentation.

new InputSimulator().Keyboard
    .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
    .TextEntry("These are your orders if you choose to accept them...")
    .TextEntry("This message will self destruct in 5 seconds.")
    .ModifiedKeyStroke(VirtualKeyCode.MENU, VirtualKeyCode.F4)
new InputSimulator().Keyboard
    .ModifiedKeyStroke(VirtualKeyCode.LWIN, VirtualKeyCode.VK_R)
    .MoveMouseToPositionOnVirtualDesktop(65535 / 2, 65535 / 2)

As we can see, it is a very useful tool for input data automation. Its use is very simple and can save us a lot of time and effort in creating applications that require keyboard and mouse input simulation.

H.InputSimulator is OpenSource and the code is available at under the Microsoft Public License (Ms-PL) license.