Q:

Creating/posting input events in C#

Is it possible to programmatically create input events in c#.
I want to be able to simulate any input, such as pressing a button on the keyboard or moving the mouse pointer from my application. The events generated by the application need to behave (preferably) in exactly the same way that an actual key press for instance does (post an event to the system event queue that is given for applications to process).
I seem to be unable to find any documentation about doing this from c# code after googling for an hour.
As always, any answers will be greatly appreciated.

A:

You can try SendKeys for keyboard input. For more control, and mouse events too, you should P/invoke SendInput().
Be warned that this is difficult to get right and you may find alternative approaches more amenable.

