Jump to content
Sign in to follow this  
motherbrainz

Need help adding timeout to script.

Recommended Posts

motherbrainz
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

 

Share this post


Link to post
Share on other sites
JohnOne

$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

  • Like 1

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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
motherbrainz

Thanks John, That works perfectly for what I am trying to do! I really appreciate it!!! :)

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
Sign in to follow this  

×