Jump to content

_WinWaitActivate with more conditional logic


ur
 Share

Recommended Posts

With _WinWaitActivate we can wait for a window to process it.

But is there any logic so that we can wait for this window title and based on the window text (like 2 or more patterns will be there) we can click yes or no on the window.

 

Func _WinWaitActivate($title,$text,$timeout=0)
 WinWait($title,$text,$timeout)
 If Not WinActive($title,$text) Then WinActivate($title,$text)
 WinWaitActive($title,$text,$timeout)
EndFunc

Edited by ur
Link to comment
Share on other sites

More specifically,

_WinWaitActivate($win1,"WARNING: This progra")
Send("{SPACE}")
_WinWaitActivate($win1,"I DISAGREE and &do n")
Send("{UP}n")

THe above logic will wait for first window and sends "Space" and wait for the second window.

But I want logic like if any of the window in the above two appears, it should send the key based on the window.

I mean parallel wait , but not sequential wait.

Anyone please suggest. 

Link to comment
Share on other sites

Hello. You can do something like this.

 

Local $iSecondsToWait = 3
Local $hTimer = TimerInit()
Local $fDiff = 0
Local $sTitleWindow1="Window1"
Local $sTitleWindow2="Window2"

While True
    $fDiff = TimerDiff($hTimer)
    If $fDiff >= $iSecondsToWait * 1000 Then
        ConsoleWrite("TimeOut" & @CRLF)
        ;Do something
        ExitLoop
    EndIf
    If WinExists($sTitleWindow1) Then
        WinActivate($sTitleWindow1)
        ConsoleWrite("Window1 Found" & @CRLF)
        ;Do something
        ExitLoop
    EndIf

    If WinExists($sTitleWindow2) Then
        WinActivate($sTitleWindow2)
        ConsoleWrite("Window2 Found" & @CRLF)
        ;Do something
        ExitLoop
    EndIf
WEnd

Saludos

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

×
×
  • Create New...