In my current project I need to send keys to a process that I have launched (I don't have any control within this process though, it is third party). Now to get these commands through, the process, EA's Origin, has to be on its main screen (that is, fully loaded after Login).
Now, I don't know how I could detect when this point has been reached. I've tried waiting for input idle, but input idle is achieved a long time before the point where I can send keys.
Is there some other method I could use to detect when the program has reached this state? I thought maybe I could detect (if) when the application signals it itself, but I'm not sure how I could find if it does signal at all, or what it signals to listen for it.
Any assistance is greatly appreciated!
If the main window has a distinct title you could enumerate windows repeatedly and wait until the process main window appears.
BTW - I have had some bad experience with send keys (sometimes keys did not get through), and I found that combining Send Key with reading the process UI (again - enum windows) works best.
Is there any visual indicator in the application, such as specific label text, that shows up when it is ready to accept input? If so you may be able to use the windows accessibility API (via P/Invoke) to watch for this and use it as a trigger. It might also be possible to use the API to watch for when the actual input control gets focus. You can even use the API instead of
SendKeys to get more reliable interaction.