Does anyone know if a Whenever can interrupt a Wait?
I have a screen where a whenever may need to execute between 0 and 8 times before we move on to the next screen. I have put in a wait for the next screen, but it seems like then Whenever will not activate once the Wait has started looking.
I have been able to get the Whenever to activate 1 time, but if the message appears more than once, the Whenever will clear the first occurance, but not the 2nd, 3rd...
I am not 100% sure, but I believe a wait statement waits for an event to happen and when it does, you go on with the script. As far as I know there is no way you can say something like "wait for this event to occur 3 times".
Anyway, it's always better to avoid a whenever. You should only use whenevers for totaly random things. But in most cases you know under which conditions a thing comes up and you should take advantage of that knowledge.
So I suggest you try something like this instead of a whenever event:
Max_Time = 10000 ;Max time in ms
If IsWindow( "PopupWindow", "exists" )
Button "OK", "Left SingleClick"
;Msgbox "SW", Clock("StopWatch")
Until Clock("StopWatch") >= Max_Time
End Function ; Main
It checks if a window exists, and if it does it deals with it. It keeps on checking and handling the windows until time runs out. You can even build in a counter if you are sure how many times the event occurs at maximum (the loop can be exited after the maximum number of times has been reached).
Anyway, I hope this helps but keep it mind it need some minor adjustments. Like the pre-set time, the windowname and the way you deal with it.
; do whatever you need to do to clear
; the exception condition
wait( 0, "any", "Event1", "Event2" )
where Event1 is the Whenever event and Event2 is the Wait event. This will wait for either of your conditions and clear the exception as often as necessary before continuing when the Wait event is satisfied.