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 "He开发者_StackOverflow社区llo" 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
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.
精彩评论