Jump to content

Need help adding timeout to script.


Go to solution Solved by JohnOne,

Recommended Posts

I am using the following command to trigger overwriting a value in the registry right after the OK button appears.  It works great as long as the "OK" button appears.  However, in some cases the "OK" button never appears because the machine does not meet a certain criteria.  My goal is to wrap this command around a timeout so that if the button never appears It wont get stuck waiting for the button indefinitely.  Maybe my approach is wrong but I can't seem to use WinWaitActive because all the window titles are the same so my command does not get triggered at the correct moment.  Thanks in advance to all.
 
;Wait & Import Registry Then Click Ok
While 1    
$var = ControlGetText("[CLASS:#32770]", "", "Button1")
Sleep(1000)
If $var = "OK" Then
Run("ImportReg.bat")
Sleep(1000)
Send("{SPACE}")
ExitLoop
EndIf
WEnd

 

Link to comment
Share on other sites

  • Solution

$SecondsToWait = 2
$Timer = TimerInit()
While TimerDiff($Timer) < ($SecondsToWait * 1000)
    $var = ControlGetText("[CLASS:#32770]", "", "Button1")
    Sleep(1000)
    If $var = "OK" Then
        Run("ImportReg.bat")
        Sleep(1000)
        Send("{SPACE}")
        ExitLoop
    EndIf
WEnd

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...