-
Create Process Problem
Hi,
Don't know whether any body will be able to help. I am using CreateProcess() to open another application from mine.
The application that is opening has a splash screen. What I need to do is wait for the program to open and then send some keyboard messages.
I am currently using Sleep() to wait for a number of seconds while the application loads. My problem is that the Splash Screen stays until my Sleep() call is over. If I sleep for 1 second or 30 seconds.
Does anybody know why? and how to solve the problem?
Thanks
-
Use the WaitForInputIdle function
if ( WaitForInputIdle(processinfo.hProcess,30000)!=0 ) {
return 0;
}
-
Yes, you should use WaitForInputIdle instead of Sleep. However I am not sure if that is what you are asking for but I don't know what you you are asking for.
-
The problem is that I need an application to start and then to send it some keyboard input before I start using it.
The problem is that the application that I am starting has a splash screen that is displayed while the application initialises. I do not want to send the keyboard input until the application main window is being displayed. (Hope this explains better)
I have tried WaitForInputIdle() but the this returns once the application has started opening and not when the Application Intialisation has completed and the main window showing.
Any ideas?
-
Have a registry entry that establishes when the initialization is complete and then only send your input.
-
I think you mean that in the Application that I am starting I should do this? (Only problem is that this is a thrid party program.) or do you mean someting else?
Could you explain more please,
Thanks
-
You could call FindWindow or FindWindowEx in your calling program to check whether the other programs window has been created or not.
-
So what establishes that the third party is initialized. Detect that if you can and then only send your input. Either find window or EnumWindows should do the work.
-
I assume the splash screen shows without any other windows for the application showing. Is the desktop the parent of the splash screen? You can use Spy++ to determine the parent. If so, then you can probably use EnumDesktopWindows to find the splash screen. You probably will need to delay doing that; if it were me, I would probably do that in a loop with a delay of a half a second or so between every enumeration of the desktop windows. Or if there is enough idenifying characteristics you can use FindWindow or something similar.
Once the splash window is found, you can check periodically to see if it is still there.
If you want to get fancy, you could set a windows hook for that process (thread actually) to monitor things.