Sign in to follow this  
Followers 0
DanDaniels

WinWaitActive on Multiple Windows

4 posts in this topic

I have an application where, after a Send() call, one of two known windows will appear.

Question: What is the most efficient method of waiting on more than one window simultaneously then branching to the appropriate code.

Thanks in advance!

Share this post


Link to post
Share on other sites



I have an application where, after a Send() call, one of two known windows will appear.

Question: What is the most efficient method of waiting on more than one window simultaneously then branching to the appropriate code.

Thanks in advance!

<{POST_SNAPBACK}>

one way is:

While 1
    if WinExists("title","text1") then 
    ; do whats needed on text1
        ExitLoop
    ElseIf WinExists("title","text2") then 
    ; do whats needed on text2
        ExitLoop
    EndIf
    sleep(10)
WEnd

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

That's a nice solution, thanks.

I was hoping there would be something that didn't require polling, but your solution is certainly acceptable.

Share this post


Link to post
Share on other sites

Basicly the same thing:

GUICreate("Random",100,100)
If Random(0,1,1) Then
    GuiCtrlCreateLabel("Success",0,0)
Else
    GUICtrlCreateLabel("Error",0,0)
EndIf
GUISetState(@SW_SHOW)


If WinWaitEither("Random","Error","Random","Success") = 1 Then
    MsgBox(0,"","Error Opened")
Else
    MsgBox(0,"","Success Opened")
Endif

Exit



Func WinWaitEither($title1,$text1,$title2,$text2)
    While 1
        If WinExists($title1,$text1) Then Return 1
        If WinExists($title2,$text2) Then Return 2
        Sleep(100)
    WEnd
EndFunc

Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0