How to Winwait for two windows simultaneously in AutoIt?

MemphiZ picture MemphiZ · Aug 14, 2010 · Viewed 14.8k times · Source

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.

Thanks in advance!

Answer

Bibz picture Bibz · Mar 25, 2014

A simpler solution might be to use a REGEX title in your WinWaitActive as defined here : http://www.autoitscript.com/autoit3/docs/intro/windowsadvanced.htm

You would then have something like this:

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

If WinGetTitle($hWnd) = "WindowWithThisTitle" then
    DoSomething()
Else
    DoSomethingElse()
EndIf