Scottswan Posted December 22, 2005 Share Posted December 22, 2005 I see that there are a number of ways to do this but I'm wondering if someone has already implemented a way so that Autoit isn't checking the clock all the time. What I want to do is run a backup utility at 2am every day. The run part is no problem, but I'm not sure of the best way to get the timing stuff done. I could use this: #include <Date.au3> MsgBox(0,'',"The time is:" & _NowTime()) And set a 24 hour sleep time before it checks the _NowTime again. Then do a little math... target_time - now_time = time_until_run_application, then set a sleep time or _TimeToTicks based on that value for the delay before the run. That way I won't be checking the time very often but I will still be in sync with the PC clock if the Autoit program stops for some reason. Better ideas? -Scott Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 I see that there are a number of ways to do this but I'm wondering if someone has already implemented a way so that Autoit isn't checking the clock all the time. What I want to do is run a backup utility at 2am every day. The run part is no problem, but I'm not sure of the best way to get the timing stuff done. I could use this: #include <Date.au3> MsgBox(0,'',"The time is:" & _NowTime()) And set a 24 hour sleep time before it checks the _NowTime again. Then do a little math... target_time - now_time = time_until_run_application, then set a sleep time or _TimeToTicks based on that value for the delay before the run. That way I won't be checking the time very often but I will still be in sync with the PC clock if the Autoit program stops for some reason. Better ideas? -Scottthat would work, but i think a 24 hour sleep is way more than you need. even if you have it wait an hour between checks, you're not even going to notice an impact to your processor usage. it may be easier to avoid the sleep completely though, and just use a task scheduler to run your program at the appropriate time... Link to comment Share on other sites More sharing options...
MrSpacely Posted December 22, 2005 Share Posted December 22, 2005 I see that there are a number of ways to do this but I'm wondering if someone has already implemented a way so that Autoit isn't checking the clock all the time. What I want to do is run a backup utility at 2am every day. The run part is no problem, but I'm not sure of the best way to get the timing stuff done. I could use this: #include <Date.au3> MsgBox(0,'',"The time is:" & _NowTime()) And set a 24 hour sleep time before it checks the _NowTime again. Then do a little math... target_time - now_time = time_until_run_application, then set a sleep time or _TimeToTicks based on that value for the delay before the run. That way I won't be checking the time very often but I will still be in sync with the PC clock if the Autoit program stops for some reason. Better ideas? -Scott Computers can calculate lots of thing in one milisecond so simpli check the @hour like every minute it won't cost much cpu then. This could work savely also display message box only once not every milisecond of a hour $donetoday = 0 $day = @yday While 1 sleep(60000); check every 60 seconds if $donetoday = 0 and @hour = 2 then msgbox(64,"Hello","Its 2 am again time to go sleep you need to wake up at 6",360); wait hour to remove the box automaticly $donetoday = 1 $day = @yday endif if ($donetoday = 1) and NOT ($day = @yday) then $donetoday = 0 $day = @yday endif Wend Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2005 Moderators Share Posted December 22, 2005 There was a similar post made this morning on 'Time' topic. I had not seen the _TicksToTime() UDF before, but it may be what your looking for.Spacely gave a good example, but I'm not a specific fan of 'Sleep()' for time functions.Take a look at this Topic and post and see if it gives you any ideas: http://www.autoitscript.com/forum/index.ph...ndpost&p=133816Also, if you do a search for 'Alarm Clock', I'm sure the Sripts and Scraps will have a few 'daily' time functions to take a look at. I know that Valauter had done some Time Function work too for a Work enviroment UDF, like clocking in and out. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
BigDod Posted December 22, 2005 Share Posted December 22, 2005 Here is an alarm clock I picked up on the forums a while back expandcollapse popup#include <GuiConstants.au3> Global $sec = @SEC, $minute, $hour, $light, $time, $clocklabel opt("WinWaitDelay", 100) opt("WinTitleMatchMode", 4) opt("WinDetectHiddenText", 1) opt("MouseCoordMode", 0) GUICreate("Max's Clock", 200, 50, (@DesktopWidth - 188) / 2, (@DesktopHeight - 59) / 2) $clocklabel = GUICtrlCreateLabel("Loading...", 5, 5, 190, 40, 0x1000) GUICtrlSetFont($clocklabel, 24) GUISetState() While 1 $msg = GUIGetMsg() If $msg = -3 Then ExitLoop ElseIf $sec <> @SEC Then GUICtrlSetData($clocklabel, TimeSet()) AlarmCheck(TimeSet()) EndIf WEnd Exit Func AlarmCheck($time) If $time = "9:00:00 PM"Then MsgBox(0,"","Time to call it a night");Alarm function(configure how wanted) EndIf EndFunc ;==>AlarmCheck Func TimeSet() $light = " AM" $hour = @HOUR $minute = @MIN $sec = @SEC If $hour = 0 Then $hour = 12 ElseIf $hour = 12 Then $light = " PM" ElseIf $hour > 12 Then $hour = (@HOUR) - 12 $light = " PM" EndIf $time = $hour & ":" & $minute & ":" & $sec & $light Return $time EndFunc ;==>TimeSet This was not written by me. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
SpookMeister Posted December 22, 2005 Share Posted December 22, 2005 Or to "think outside the box" as it were... you could always just schedule the job to run daily with windows built-in Scheduled Tasks. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 22, 2005 Moderators Share Posted December 22, 2005 Or to "think outside the box" as it were... you could always just schedule the job to run daily with windows built-in Scheduled Tasks.Actually... wouldn't that be considered 'inside the box' Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 Actually... wouldn't that be considered 'inside the box' that's what i was thinking when i suggested it in the first reply... Link to comment Share on other sites More sharing options...
SpookMeister Posted December 22, 2005 Share Posted December 22, 2005 (edited) @ Smoke @ Cam dangit... missed that Edited December 22, 2005 by SpookMeister [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote] Link to comment Share on other sites More sharing options...
Scottswan Posted December 22, 2005 Author Share Posted December 22, 2005 Or to "think outside the box" as it were... you could always just schedule the job to run daily with windows built-in Scheduled Tasks.I thought about that at first, then I discovered that the backup utility (xxclone) won't let me use a command line 'run' unless I cough up $40 for the pro version. So I need something that can actually hit {Enter}.Plus there are a couple other 'batch' style jobs I need to run daily and some hourly on this machine so I figured I'd just make it all work with Autoit.The machine is going to be an un-manned server running a portal for a small company.Thanks for the tips so far, I need to look into the other tips yet.-Scott Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 I thought about that at first, then I discovered that the backup utility (xxclone) won't let me use a command line 'run' unless I cough up $40 for the pro version. So I need something that can actually hit {Enter}.Plus there are a couple other 'batch' style jobs I need to run daily and some hourly on this machine so I figured I'd just make it all work with Autoit.The machine is going to be an un-manned server running a portal for a small company.Thanks for the tips so far, I need to look into the other tips yet.-Scottwhile we're talking about autoit based solutions... why do you need a command line? why can't you just controlsend the "{ENTER}" or controlclick on the "i agree to the terms imposed by my using the cheap version" box? and still use regular scheduler... Link to comment Share on other sites More sharing options...
Scottswan Posted December 22, 2005 Author Share Posted December 22, 2005 (edited) while we're talking about autoit based solutions... why do you need a command line? why can't you just controlsend the "{ENTER}" or controlclick on the "i agree to the terms imposed by my using the cheap version" box? and still use regular scheduler...There's a thought. Just have ms scheduler run an Autoit script that runs xxclone and then hits {enter}, which is defaulted to the 'start' button on the xxclones gui, then end the script... done!Duh! Edited December 22, 2005 by Scottswan Link to comment Share on other sites More sharing options...
seandisanti Posted December 22, 2005 Share Posted December 22, 2005 There's a thought. Just have ms scheduler run an Autoit script that runs xxclone and then hits {enter}, which is defaulted to the 'start' button on the xxclones gui, then end the script... done!Duh! sometimes it just takes hearing it from someone else. glad i could help. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now