.NET: Can one program feed events to another?

Using VisualStudio.NET, I’d like to create a program that generates keystroke events for another program that consumes them. (The idea is to be able to test the second program without actually having to sit at a keyboard and press keys.)

Is this possible?

I can’t remember the specific function call off the top of my head, but something here might be helpful.

I can’t think of anything specific in .NET that would do what you want, but you can write either a Keyboard hook or Journal playback hook.

There is a great book that has a few chapters devoted to this called Windows 95 A developer’s Guide buy Jeffrey Richter and Jonathan Locke. Chapters 6 and 8 talk about the various ways you could achieve what you want to do and why he chose to solve the problem the way he did. Don’t worry that was written for Windows 95, the concepts are still the same. The book is probably out of print, but you can likely get a used copy off of Amazon

Okay, I knew that there had to be an easier way to do this, so I looked through my MSDN a bit…

I’ve had experience using sendkeys in VB6, so that’s why I knew what dot net terms to try looking under.

Thanks to all - most useful.