Page 1 of 1

WaitProgramInitialisation

Posted: Tue Nov 29, 2005 11:04 am
by Droopy
Code updated for 5.20+

This function is usefull for sending key, and be sure the program is initialised.

Code: Select all

;/ Author : Bingo
; The WaitProgramInitialisation function waits Until The specified process is waiting For user input 
; with no input pending, Or Until The time-out interval has elapsed.
; If this process is a console application or does not have a message queue, 
; WaitProgramInitialisation returns immediately. 

Procedure WaitProgramInitialisation(Handle)  
  While  WaitForInputIdle_(Handle, 1) > 0 
    Debug "Initialisation ..."
    Delay(1) 
  Wend 
EndProcedure

;/ Test
ret = RunProgram("Calc.exe") 
If ret
  WaitProgramInitialisation(ret)
EndIf
Debug "Launched & Ready."
Thanks to Bingo

Re: WaitProgramInitialisation

Posted: Tue Nov 29, 2005 11:22 am
by PB
Nice tip, Bingo -- and thanks for letting us know, Droopy! :)

Normally I'd launch and watch for the app's window to appear (in a loop),
but this is so much cleaner and more efficient -- and doesn't depend on
the title text either (which is good for different languages).

Re: WaitProgramInitialisation

Posted: Sat Jan 21, 2006 7:56 am
by PB
@Fred: Maybe the RunProgram command could have the flags changed, and
the tip above added? I was thinking something like this:

1: Launch the program in invisible mode
2: Wait until the launched program is ready
3: Wait until the launched program quits

What do you think?

(And to those who think the new numbers will confuse things, it's easy enough
to just renumber them manually... the numbers above make more sense due
to being numbered in the sequence that the app is launched).