Jump to content
Sign in to follow this  
BrendanB

Need to pause a script daily at a certain time...

Recommended Posts

BrendanB

Hi guys,

I'm back. I need to implement yet another piece to my ever-growing monstrosity (err.. script..) that pauses its execution. My script is meant to run continuously, but it must pause for two hours nightly, between 11PM and 1AM, so a server can finish its backup. How and where in my script should I implement this function? At the very beginning of the loop?

Share this post


Link to post
Share on other sites
Generator

Just check out the help file, here are some ideas.

_NowTime

--------------------------------------------------------------------------------

Returns the current Time in requested format.

#Include <Date.au3>

_NowTime ( [$sType] )

You can use like this

AdibeEnable("_Check",100)
While 1
If $Time="23:00:00" Then
Do
Sleep(1000)
Until $Time=1:00:00
EndIf
WEnd
Func _Check()
$Time=_NowTime(5)
EndFunc

Share this post


Link to post
Share on other sites
BrendanB

Just check out the help file, here are some ideas.

You can use like this

AdibeEnable("_Check",100)
While 1
If $Time="23:00:00" Then
Do
Sleep(1000)
Until $Time=1:00:00
EndIf
WEnd
Func _Check()
$Time=_NowTime(5)
EndFunc
Hmm.. keeps asking me for an "Until <expr>" value. I'll look into this function and see what I can come up with. Any other ideas are certainly welcome!

Thanks!

Share this post


Link to post
Share on other sites
Valuater

Bottom of the 1st page

#133769

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
BrendanB

Bottom of the 1st page

#133769

8)

Thanks. I tried using your code to quit a server app (I have to do two things here). I have to quit this server app and tell a script on another machine to pause, while a third machine (the server) runs its backup. Anyway, for the server-app-quit-script, it's real simple, but it does not work. It needs to run in a continuous loop, so that it can quit the app at one time, and re-launch it at another time, daily:

$start = 09 & ":" & 08 ;testing time
$start2 = 09 & ":" & 10 ;testing time
While 1
    $start3 = @HOUR & ":" & @MIN
    If $start = $start3 Then ;Quittin' time
        WinActivate("FilePower Disc Server A")
        Send("!{F4}")
        WinWaitActive("FilePower") ;The "Are you sure?" dialog box
        ControlClick("FilePower", "", 6) ;The "Yes" button
    EndIf
    If $start2 = $start3 And not WinExists("FilePower Disc Server A")
    Then
        Run("I:\WINAPPS\JBSERVER.EXE")
    EndIf
    ContinueLoop
WEnd
Exit

Share this post


Link to post
Share on other sites
PsaltyDS

Thanks. I tried using your code to quit a server app (I have to do two things here). I have to quit this server app and tell a script on another machine to pause, while a third machine (the server) runs its backup. Anyway, for the server-app-quit-script, it's real simple, but it does not work. It needs to run in a continuous loop, so that it can quit the app at one time, and re-launch it at another time, daily:

Your WinWait's will hang. The while loop will repeat the check in much less than a minute, so the time will still match, but the window will not exist anymore...

:rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
BrendanB

Your WinWait's will hang. The while loop will repeat the check in much less than a minute, so the time will still match, but the window will not exist anymore...

:rolleyes:

Thanks for the heads up, PsaltyDS. I have reworked the script and it works fine now. (I used a Do loop instead, with some Sleeps thrown in). I'm sure the code is convoluted, but it appears to work correctly now (that's all that matters, right? :rambo:)

$v1 = 0 ;Do loop variable.
$start = 23 & ":" & 30 ;Quit time.
$start2 = 01 & ":" & 00 ;Run time.
Do
    $start3 = @HOUR & ":" & @MIN
    If $start = $start3 Then
        WinActivate("FilePower Disc Server A")
        WinClose("FilePower Disc Server A")
        WinWaitActive("FilePower")
        ControlClick("FilePower", "", 6)
        Sleep(70000) ;Sleep for 70 seconds, so as not to repeat this step.
    EndIf
    If $start2 = $start3 Then
        Run("O:\WINAPPS\JBSERVER.EXE")
        Sleep(70000) ;Sleep for 70 seconds, so as not to repeat this step.
    EndIf
ContinueLoop
Until $v1 = 1 ;This will never occur, due to the ContinueLoop call.
Exit
Edited by BrendanB

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  

×