Take the 2-minute tour ×

I'm using the Input Simulator library to simulate input to another application using C#, this uses the SendInput API calls. Does anyone know if there is a way I can monitor the windows message queue for the external application to see if those messages have been processed?

For example, let's say I want to send the keystrokes for the word "Hello" to notepad, but I don't want my application to continue until notepad has received and processed the input and the word "Hello" has appeared in the notepad window. We'll know this has happened once the keypress messages are no longer in the message queue for notepad, but I can't work out how to find that out.

I was using the .NET SendKeys class and using SendWait, but this seems unstable and causes occasional freezes in the external application, so after weeks of trying to fix that I'm looking for a new method.

Many thanks

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can't. Calling SendInput ultimately results in posted messages which are delivered asynchronously.

Why fake input to Notepad when you can send the text direct to the edit window? Not only would it be way simpler it would be robust and synchronous.

share|improve this answer
Notepad was just an example app. I'm using this as part of an automated testing process, and want to simulate things at the highest possible level making sure all events that should be fired are fired. Therefore I'm simulating mouse movement, mouse clicks and I'd like to get this working properly too. It sounds like I might just need to stick in a Thread.Sleep() though. –  Will Calderwood Mar 10 '11 at 18:49

Your Answer


