Burgs Posted June 10, 2008 Share Posted June 10, 2008 Greetings, I'm trying to write a simple scheduler to run a program every "5 + 1" minutes, for example on minutes during the hour of "01, 06, 11, 16, 21, 26, 31, 36, 41, 46, 51, 56". I know it requires a loop however I do not know the proper command syntax to set the minutes correctly. Any help appreciated. Link to comment Share on other sites More sharing options...
Airwolf Posted June 10, 2008 Share Posted June 10, 2008 While 1 If (StringRight(@MIN, 1) = 1) Or (StringRight(@MIN, 1) = 6) Then ;if current minute ends in 1 or 6 ;run your program here EndIf Sleep(60000) ;pause for 60 seconds - you may want to change this, but if the program execution does not take at least a minute then it will run twice WEnd Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
muncherw Posted June 10, 2008 Share Posted June 10, 2008 While 1 If (StringRight(@MIN, 1) = 1) Or (StringRight(@MIN, 1) = 6) Then ;if current minute ends in 1 or 6 ;run your program here EndIf Sleep(60000) ;pause for 60 seconds - you may want to change this, but if the program execution does not take at least a minute then it will run twice WEnd Interesting. And a lot more elegant than I would have thought about doing it. Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic] Link to comment Share on other sites More sharing options...
Airwolf Posted June 10, 2008 Share Posted June 10, 2008 Interesting. And a lot more elegant than I would have thought about doing it.You could simplify it even more using StringRegExp(). While 1 If StringRegExp(@MIN, "[16]") = 1 Then ;if current minute ends in 1 or 6 ;run your program here EndIf Sleep(60000) ;pause for 60 seconds - you may want to change this, but if the program execution does not take at least a minute then it will run twice WEnd The beauty of programming is the endless number of ways to obtain the same output. Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted June 10, 2008 Share Posted June 10, 2008 (edited) Something like this should also work= (untested) While 1 If StringIsDigit((@MIN-1)/5) = 1 Then;if current minute ends in 1 or 6 ;run your program here EndIf Sleep(60000);pause for 60 seconds - you may want to change this, but if the program execution does not take at least a minute then it will run twice WEnd Edited June 10, 2008 by AdmiralAlkex .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
Burgs Posted June 10, 2008 Author Share Posted June 10, 2008 Thanks for the help everybody! One final question, the application will run less than a minute, I thought of adding a "control" variable to prevent the script from running more than once but I'm getting an error, can somebody explain the problem with this? (it doesn't like the "Return" part...) Dim $Control = 0 if($Control == 1) Then Return EndIf While 1 If (StringRight(@MIN, 1) = 1) Or (StringRight(@MIN, 1) = 6) Then ;if current minute ends in 1 or 6 ;run your program here Run("C:\SegFiles\Process.exe", "", @SW_MAXIMIZE) $Control = 1 EndIf Sleep(60000) ;pause for 60 seconds - you may want to change this, but if the program execution does not take at least a minute then it will run twice WEnd Link to comment Share on other sites More sharing options...
Valuater Posted June 10, 2008 Share Posted June 10, 2008 1. return is used from inside a UDF 2. it is written either... If ($Control == 1) Then Return ; with no "EndIf" or..... If ($Control == 1) Then ; do something Return EndIf how about this, it only sleeps for 1 min when the prog is ran? While 1 If (StringRight(@MIN, 1) = 1) Or (StringRight(@MIN, 1) = 6) Then ;if current minute ends in 1 or 6 ;run your program here Run("C:\SegFiles\Process.exe", "", @SW_MAXIMIZE) Sleep(60000) EndIf Sleep(10) WEnd Very Important, Scite can test the syntax for errors ... just click "sytaxcheckprod" under "tools" 8) Link to comment Share on other sites More sharing options...
Burgs Posted June 10, 2008 Author Share Posted June 10, 2008 Thank you for the reply, that's a great help to me! 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