Search code examples
windowswaitautoit

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.


Solution

  • 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