Many of the part of windows works on messages – windows messages. One code can send different kind of messages to another application using Windows API. Keyboard messages and mouse messages are one of them.
.NET is one more layer above OS, e.g. Windows. If someone needs to emulate keyboard strokes to another application from .NET there is a choice of using .NET class library. To emulate keyboard events from .NET it’s easier to use
- System.Windows.Forms.SendKeys.Send(string) and
- System.Windows.Forms.SendKeys.SendWait(string)
Recently, I used this to auto log into a application that I’m developing if it’s debug build. Just to get a change from AutoHotKey.
The problem of this is it sends keystrokes to only active application.