marko001 Posted April 4, 2008 Share Posted April 4, 2008 Hi all. Please can you help me with this?The problem i have is that i always get a $processpid=ProcessExists($PIDGame) = 0 , but the $pidgame is <>0. ( i mean, the GAME IS up!)What i want is to wait until the game spawns (become active) then continuing loop. I want to avoid to use sleep(15000), i prefer a structured solution:while 1 bla bla bla _launch(1) _gameup(1) _start(1) bla bla blawendfunc _launch($i) Select case $i=1 $tempname = StringTrimRight($s_gamepath1,4) $tempname2 = $tempname & " /driver:" & $s_gamedriver $PIDgame1=Run($tempname2,$s_g1folder, @SW_MAXIMIZE) sleep(15000) (if i want it to work i need to use that! but i don't like) _Gameup($i) case $i=2 $tempname = StringTrimRight($s_gamepath2,4) $tempname2 = $tempname & " /driver:" & $s_gamedriver $PIDGame2=Run($tempname2,$s_g2folder, @SW_MAXIMIZE) sleep(15000) _Gameup($i) EndSelectEndFuncfunc _gameup($k) local $wait $wait = 1 While $wait <>0 if $k=1 Then $processpid=ProcessExists($PIDGame1) And i always get 0!!! if $processpid = 0 then $wait = $wait + 1 Else $wait = 0 EndIf ElseIf $k=2 Then $processpid=ProcessExists($PIDGame2) if $processpid = 0 then $wait = $wait + 1 Else $wait = 0 EndIf EndIf if $wait = 500 Then $wait = 0 (only way to exit) EndIf WEnd _status($k,"Game" & $k & " is up!") EndFuncThanks a lot,Marco Link to comment Share on other sites More sharing options...
redsleeves Posted April 5, 2008 Share Posted April 5, 2008 Have you looked at ProcessWait ? $PIDgame1=Run($tempname2,$s_g1folder, @SW_MAXIMIZE) ProcessWait ($tempname2,15) Link to comment Share on other sites More sharing options...
marko001 Posted April 5, 2008 Author Share Posted April 5, 2008 Have you looked at ProcessWait ? $PIDgame1=Run($tempname2,$s_g1folder, @SW_MAXIMIZE) ProcessWait ($tempname2,15) i tried. In fact it works but doesn't solve my problem since the game need few seconds before spawning but the become =1 as soon as i run the game. That means (correct me if i'm wrong) that in any case i need to give a sleep (15000) ... Correct? Marco Link to comment Share on other sites More sharing options...
redsleeves Posted April 6, 2008 Share Posted April 6, 2008 Between the time that the process is spawned and the game is ready there is a period of some time, correct? Would you be able to wait for a specific control to appear when the game was ready? Could you use ProcessWait until the process is created and then pause the script until a specific control or window title becomes available? Link to comment Share on other sites More sharing options...
marko001 Posted April 6, 2008 Author Share Posted April 6, 2008 Between the time that the process is spawned and the game is ready there is a period of some time, correct?Would you be able to wait for a specific control to appear when the game was ready? Could you use ProcessWait until the process is created and then pause the script until a specific control or window title becomes available?Yes this could help me. In fact once launched it takes around 10 secs before spawning. How can i check (and continue script) when the game window is spwned? Link to comment Share on other sites More sharing options...
redsleeves Posted April 8, 2008 Share Posted April 8, 2008 If you can get the title of the game window when it is ready, you could use that with WinWaitActive() Do Until WinExists ( "Untitled - Notepad" ) WinWaitActive("Untitled") You could also wait until a window no longer exists with: WinWaitNotActive("Untitled") You may want to check out AutoItSetOption and WinWaitDelay, as well. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now