How can I emulate a keyboard in an application running in the background (hidden in a tray). I want to press, hold and change the keys on the keyboard programmatically. In addition, I would like to move the mouse and be able to click.
You can use the SendInput API function
You can also try the Windows.Forms.SendKeys API
Here is a How-To: Practical Guide. Modeling mouse and keyboard events in code