mrddr6 Posted December 6, 2007 Share Posted December 6, 2007 I am trying to make a script that will run itself at a set time of day. Such as at 6:00 am. Any help would be great. Link to comment Share on other sites More sharing options...
GEOSoft Posted December 6, 2007 Share Posted December 6, 2007 I am trying to make a script that will run itself at a set time of day. Such as at 6:00 am. Any help would be great. A script can not open itself. You could open it with a task scheduler OR you could write another script that loads on system start-up and stays idle until a certain time before triggering the script you want to run. Or You can load your script at startup and have it stay idle until a certain time. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
mrddr6 Posted December 6, 2007 Author Share Posted December 6, 2007 A script can not open itself. You could open it with a task scheduler OR you could write another script that loads on system start-up and stays idle until a certain time before triggering the script you want to run. Or You can load your script at startup and have it stay idle until a certain time.I already have a script that loops over and over, is there any way I can add some script to that one that will only run if it is 6:00 am? Link to comment Share on other sites More sharing options...
herewasplato Posted December 6, 2007 Share Posted December 6, 2007 If @HOUR = 6 Then _MoreStuff() put that in you loop [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
GEOSoft Posted December 6, 2007 Share Posted December 6, 2007 I already have a script that loops over and over, is there any way I can add some script to that one that will only run if it is 6:00 am?If @Hour = 6 And @Min = 0 AND @Sec <2 Then Sleep(1000) myFunction() EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
GEOSoft Posted December 6, 2007 Share Posted December 6, 2007 If @HOUR = 6 Then _MoreStuff()put that in you loopThat can be a bit dangerous (from experience). @Hour will be 6 for 60 minutes. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
herewasplato Posted December 6, 2007 Share Posted December 6, 2007 (edited) That can be a bit dangerous (from experience). @Hour will be 6 for 60 minutes.Yep - I was going to let the OP learn that :-) I had coded a few other ways to handle that issue, but it depends on how his loop is setup and what else it is doing. Edit1: One example would be if the OP inserted your code into a loop like this: While 1 Sleep(10000) If @HOUR = 6 And @MIN = 0 And @SEC < 2 Then Sleep(1000) myFunction () EndIf WEndThe ten second delay might cause the trigger window to be missed. Edit2: The simplest way might be to have the script of interest start when the computer starts and have that script idle until it is 6AM using a do/sleep/until loop. Edited December 6, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
GEOSoft Posted December 6, 2007 Share Posted December 6, 2007 Yep - I was going to let the OP learn that :-) I had coded a few other ways to handle that issue, but it depends on how his loop is setup and what else it is doing. Edit1: One example would be if the OP inserted your code into a loop like this: While 1 Sleep(10000) If @HOUR = 6 And @MIN = 0 And @SEC < 2 Then Sleep(1000) myFunction () EndIf WEndThe ten second delay might cause the trigger window to be missed. Edit2: The simplest way might be to have the script of interest start when the computer starts and have that script idle until it is 6AM using a do/sleep/until loop.Right you are He would then have to change the @Sec < 2 in my code to @Sec < 12. An example of your method would be (for the OPs sake) Do Sleep(10000) Until @Hour = 6 That would exit the loop anytime from (@Hour = 6) to (@Hour = 6 AND @Sec = 10) George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
mrddr6 Posted December 7, 2007 Author Share Posted December 7, 2007 Thanks for the help, my script works great now. I dont have to get up early! Link to comment Share on other sites More sharing options...
jmilo Posted December 7, 2007 Share Posted December 7, 2007 I am trying to make a script that will run itself at a set time of day. Such as at 6:00 am. Any help would be great. Why dont you just use the task scheduler in windows located in the control panel Link to comment Share on other sites More sharing options...
weaponx Posted December 7, 2007 Share Posted December 7, 2007 That can be a bit dangerous (from experience). @Hour will be 6 for 60 minutes.What are you talking about? If my clock shows 11:43, @Hour will show 11 Link to comment Share on other sites More sharing options...
GEOSoft Posted December 7, 2007 Share Posted December 7, 2007 What are you talking about? If my clock shows 11:43, @Hour will show 11Give the head a shake lad. Not too hard though, wouldn't want to lose anything or set something to rattling.If your clock shows 11:00:00 it's going to show @hour as 11 right up until 11:59:59.Now a little bit of math and you can figure out just how many minutes that is. To hard for me today. Maybe tomorrow I'll write a script to do it as long as it won't be longer than 3 lines. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
weaponx Posted December 7, 2007 Share Posted December 7, 2007 I see what you mean. It just wasn't clear when you said @HOUR will be 6 for 60 minutes, I took that as @HOUR will be 60. So in closing, definitely check that the minutes are zero if you have to run at the exact beginning of an hour. Link to comment Share on other sites More sharing options...
herewasplato Posted December 8, 2007 Share Posted December 8, 2007 ...it depends on how his loop is setup and what else it is doing...Okay, before anyone comments - I know that I'm quoting myself... I talk to myself, so why can't I quote myself??? Anyway, I see that the OP has a solution now - but I wanted to mention this simple loop:While 1 Do Sleep(10000) Until @HOUR = 6 ;do stuff at about 6 AM Do Sleep(10000) Until @HOUR = 7 ;do stuff at about 7 AM or do nothing WEndAs long as you have at least one other loop like above - you need not worry that @HOUR will = 6 for 60 minutes. If just depends on the resolution that you need... but I've never used AutoIt for task scheduling - that is what the OS's task scheduler is for. :-) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
GEOSoft Posted December 8, 2007 Share Posted December 8, 2007 So in closing, definitely check that the minutes are zero if you have to run at the exact beginning of an hour.Thats right. Just don't set @Sec to 0. It's to easy to miss it in a loop like that. In that case you would use If @Sec<=1 Then or If @Sec <=2 Then. That gives you a bit of room so you don't miss the actual occurence of @Sec being 0 because of the sleep. Of course in this case I don't think the OP needs that precision anyway. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
boomingranny Posted December 11, 2007 Share Posted December 11, 2007 i take it you only want it to run once daily? so instead why not use a last run variable that records the date the task itself last run... and save it to an ini if you like. that way you have a 60 minute window (using @hour = X) and you can use a longer sleep period, and it will only run once daily. just a suggestion. eg. #include <Date.au3> $Lastrun = iniread ("scheduler.ini", "general", "LastRun","1900/01/01") while 1 Do sleep(60000);sleep for a minute until @hour = 11 and $LastRun <> _NowCalcDate() $LastRun = _NowCalcDate() IniWrite ("scheduler.ini", "general", "LastRun",$LastRun) msgbox (0, "Some Stuff to do here","Some Stuff to do here") wend 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