Jump to content

WinWaitActive on Multiple Windows


Recommended Posts

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!

Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...