ur

_WinWaitActivate with more conditional logic

3 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
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. 

Share this post


Link to post
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


 

venezuela.png Would you like to say thank to Danyfirex using a warmy way?  offer me a cup of coffee... coffee.png

autoit_scripter_blue_userbar.png

       AutoIt...

 

 

Share this post


Link to post
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

  • Similar Content

    • nacerbaaziz
      By nacerbaaziz
      Hi dear
      I have a question
      about the display language of the system
      How can I get the current display language and how can I change it by autoit
      Of course, if this is possible
      Greetings to all and hope you help me
    • breakbadsp
      By breakbadsp
      AutoIT AU3info doeas not detect all gui objects uniquely for .NET GUIs developed in C#.
      this is not working now i am using COM windows approach for this, But its very difficult.
      Please let me know if anyone has done it before.
    • wtarkan
      By wtarkan
      If I create a service to run a program , Application window cannot Appear - How can I make the App window visible
    • ur
      By ur
      Whenever we try to access a network share it will prompt for credentials based on the shared folder settings.
      Like the below prompt


      Once you save them, they are saved in Windows Credentials of Credentials Manager in Control panel (run --> control keymgr.dll).

       
      But not able to found exact file or registry for this setting.
       
      So, can anyone suggest how to do this process of adding network credentials using AutoIT.
       
    • onlineth
      By onlineth
      Basically, I want to unlock a user account by executing a script (while a user see's their locked screen, if this script is executed in the background, it unlocks their account without having to type in any password). In a perfect world, I would have a service running that can automatically log specific users in whether their account is locked or they just turned their computer on and no users have been logged in yet.
      I don't want to have anything special enabled on the computer (like the remote desktop workaround). I can provide the actual password to the account and I would like this to be compatible on Windows 7.
      Has anyone come across any script that can do this? If there isn't a way to unlock the computer from startup, is there at least a way to unlock the account that's currently already logged into but just has the lock screen up?