CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Dec 2003
    Location
    Omagh
    Posts
    133

    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

  2. #2
    Join Date
    Sep 1999
    Location
    France
    Posts
    393
    Use the WaitForInputIdle function

    if ( WaitForInputIdle(processinfo.hProcess,30000)!=0 ) {
    return 0;
    }

  3. #3
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    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.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

  4. #4
    Join Date
    Dec 2003
    Location
    Omagh
    Posts
    133
    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?

  5. #5
    Join Date
    Apr 2001
    Location
    San Diego CA
    Posts
    378
    Have a registry entry that establishes when the initialization is complete and then only send your input.

  6. #6
    Join Date
    Dec 2003
    Location
    Omagh
    Posts
    133
    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

  7. #7
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507
    You could call FindWindow or FindWindowEx in your calling program to check whether the other programs window has been created or not.

  8. #8
    Join Date
    Apr 2001
    Location
    San Diego CA
    Posts
    378
    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.

  9. #9
    Join Date
    May 1999
    Location
    Southern California
    Posts
    12,266
    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.
    "Signature":
    My web site is Simple Samples.
    C# Corner Editor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured