Event Driven Delays
Keywords: TimeDelay RunWait Delay Wait
How do I create an event driven pause or delay? How can I make the script
wait until a certain application has finished its processing?
There is no single command which will delay the .WBT script and wait for an event to occur.
However, you have several options for creating the delay, including:
- Use the TimeDelay command. However, in using this the maximum estimated time
interval must be specified, therefore
this is the least elegant of your possible solutions.
- IntControl(36, p1, p2, 0, 0) (32-bit version only).
Waits until an application is waiting for user input.
- Use the RunWait command. Not always applicable.
- Learn something about the application which is traceable. Example things you can check for:
files that exist, windows, dialog boxes, system resource percents, etc.
What does it do? Make a file on disk (FileExist)? Update a file (FileTimeCode)? Make any registry entries (regqueryvalue)?
For example, a dialog box may be displayed when printing is in progress.
Write a loop in the script which checks for the existence of the dialog box.
When the dialog box closes, the script will continue.
The idea is to figure out some way of telling when an application is done.
Does anything on the screen change. Did some file
suddenly appear? You need something you can get your hands on.
For example:
- A window appears "Done":
WinWaitExist("Done")
;or maybe
WinWaitChild("MS Access","Done")
or, something like:
while WinExist("Notepad")
delay(2)
endwhile
- You can do a "FileExist" on the file
until it appears, and then do a FileSize
on it till there is a non-zero file size.
That generally indicates completion.
fname="c:\xxx\output.txt"
while !FileExist(fname)
TimeDelay(1)
endwhile
while FileSize(fname)==0
TImeDelay(1)
endwhile
- Windows on the screen change:
This handy script helps you see what is going on, in terms of parent and child window names:
parents=WinItemize()
thisone=AskItemList("Choose a Parent Window",parents,@tab,@sorted,@single)
children=WinItemChild(thisone)
child=AskItemList("Children of %thisone%",children,@tab,@sorted,@single)
The WinItemChild() along with a strindex might be most helpful.
Article ID: W12988
Filename: Event Driven Delays.txt
File Created: 1999:04:15:16:51:00
Last Updated: 1999:04:15:16:51:00