Iceburg Posted July 26, 2009 Share Posted July 26, 2009 I have a script that I am trying to set up that will run on a computer 24/7. I have set the loop up to pull the current time, and then compare that time to my "schedule" and then run the scripts based on those times. I have two issues that I would like some help on with this script. 1.) It doesn't work for some reason. The time gets pulled, but it never launches the test schedule (just the message box that comes up with a different title) 2.) If the script runs at 1:00:00 when I start it, and it takes 2ms for the code to run, and the time doesn't match anything, then its going to sleep for 60 seconds. The next time its going to run is at 1:01:02, the time for the code has potential to add up and then skip a minute after the code has been running for days/weeks/months. How can I account for the time that it takes the code to run to verify 100% that I will never miss a schedule? while 1 $time = @hour & ":" & @MIN ; Pull current time ;MsgBox(4096, "time", $time) If $time == ("02:00") then Run ("c:\windows\pskill.exe\simple.exe") ; Run script at 2:00a.m. ElseIf $time == ("07:30:00") then Run ("C:\Documents and Settings\Owner\Desktop\simple.exe") ; run script at 7:30a.m. Elseif $time == ("15:00") Then MsgBox(4096, "HURRAY", $time) ; Test time to run test script else sleep (60000) ; Sleep for 1 min, and check time again EndIf WEnd Link to comment Share on other sites More sharing options...
DCCD Posted July 26, 2009 Share Posted July 26, 2009 Hi there! ;@Hour ,24-hour format. Range is 00 to 23 ;@MIN ,Range is 00 to 59 While 1 If @HOUR = 19 And @MIN = 53 Then MsgBox(4096, "", @HOUR & ':' & @MIN) ExitLoop EndIf WEnd [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Iceburg Posted July 26, 2009 Author Share Posted July 26, 2009 What do you think about time issue with the seconds / ms? I will try that out and check it out. Link to comment Share on other sites More sharing options...
BrettF Posted July 26, 2009 Share Posted July 26, 2009 You have a problem sleeping here: sleep (60000) Try sleeping for a smaller value. Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
corgano Posted July 26, 2009 Share Posted July 26, 2009 While @SEC <> 0 ;it will wait untill the end of the minit. mess with this to get to the closest second on the minuit as posible Sleep(100) WEnd ; then start AdlibEnable(time(),30000) Func Time() $time = @hour & @MIN EndFunc while 1 ConsoleWrite($time & @CRLF) If $time == (200) then Run ("c:\windows\pskill.exe\simple.exe") ; Run script at 2:00a.m. sleep(90000) ; prevent from running it a thousand times ElseIf $time == (730) then Run ("C:\Documents and Settings\Owner\Desktop\simple.exe") ; run script at 7:30a.m. sleep(90000) ; prevent from running it a thousand times Elseif $time == (2057) Then MsgBox(4096, "HURRAY", $time) ; Test time to run test script sleep(90000) ; prevent from running it a thousand times Else Sleep(30000) EndIf WEnd I got it to run on time, the additional sleeps are to make sure it does not run scheduled tasks an any given time. This will guaranteed always get the time at 30 secs. 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e 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