Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Winwait for two windows simultaneously in AutoIt?

I would like to know if its possible to WinWaitActive for WindowWithThisTitle and WindowWithThatTitle at the same time. I'm executing a command and there could be a window telling me that the connection failed or a user/pass dialog coming up.

Is there another way doing it as this?

WinWaitActive("Title1", "", 5)
If(WinExists("Title1")) Then
 MsgBox(0, "", "Do something")
Else
 If(WinExists("Title2")) Then
  MsgBox(0, "", "Do something else")
 EndIf
EndIf

Because I don't want to have the timeout which could be more than 15 seconds.

like image 679
MemphiZ Avatar asked Aug 14 '10 00:08

MemphiZ


2 Answers

A simpler solution might be to use a REGEX title in your WinWaitActive as defined here

You would then have something like this:

$hWnd = WinWaitActive("[REGEXPTITLE:(WindowWithThisTitle|WindowWithThatTitle)]")

If WinGetTitle($hWnd) = "WindowWithThisTitle" then
    DoSomething()
Else
    DoSomethingElse()
EndIf
like image 140
Bibz Avatar answered Sep 30 '22 03:09

Bibz


How about something like this.

$stillLooking = True
While $stillLooking
    $activeWindowTitle = WinGetTitle(WinActive(""))
    If $activeWindowTitle == "Title1" Then
        MsgBox(0, "", "Do something")
        $stillLooking = False
    ElseIf $activeWindowTitle == "Title2" Then
        MsgBox(0, "", "Do something else")
        $stillLooking = False
    EndIf
    sleep(5)
WEnd

Because I don't want to have the timeout which could be more than 15 seconds.

WinWaitActive() doesn't have a timeout unless you specify one. You gave it a five second timeout but you could leave that off and it would wait forever.

like image 20
Copas Avatar answered Sep 30 '22 03:09

Copas