|
-
Apr 10th, 2011, 11:17 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Wait until a process' main Window is displayed
Hello everyone.
I am working on a game launcher, and I need to display a "Splash screen" until the main game has started. For this, I need to know whether or not the Process has a Main window that is fully loaded and displayed.
Now I noticed the main window handle is 0 when there is none, so I tried to use that:
Code:
p.Start()
Do While p.MainWindowHandle = IntPtr.Zero
Threading.Thread.Sleep(100)
Loop
MsgBox("Game window displayed")
But the handle never becomes nonzero. I tried to use the title but to no avail.
I do not want to go into "Thread.wait()" since then the splash would remain even if the game is already launched.
Any help on this?
-
Apr 10th, 2011, 07:08 PM
#2
Hyperactive Member
Re: Wait until a process' main Window is displayed
Does the Application Framework works for you?
Based on what you have described, it is possible with VB2005 via Application Framework. You can even set the delay before the splashscreen is closed after the main form is ready to be loaded.
-
Apr 10th, 2011, 07:21 PM
#3
Re: Wait until a process' main Window is displayed
 Originally Posted by bergerkiller
But the handle never becomes nonzero.
Just a guess, but have you tried refresh?
Code:
Do While p.MainWindowHandle = IntPtr.Zero
Threading.Thread.Sleep(100)
p.Refresh()
Loop
-
Apr 10th, 2011, 08:20 PM
#4
Re: Wait until a process' main Window is displayed
You could try calling WaitForInputIdle on the Process.
-
Apr 11th, 2011, 06:30 AM
#5
Thread Starter
Fanatic Member
Re: Wait until a process' main Window is displayed
Thanks edge and jmcil, both working answers.
Never used inputidle because I thought it was related to the "StandardOutput" or "StandardInput" streams, but that is not the case as I know now. 
Didn't know you had to refresh a process, thought all the process' properties did was get the information from the system, instead of storing them internally...
I guess I'll use the "WaitForInputIdle()" function, since it is shorter and seems more reliable than checking the handle.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|