seesoe 0 Report post Posted April 3, 2009 is there a way to monitor the system time and do something at say like 10am? Share this post Link to post Share on other sites
SmOke_N 199 Report post Posted April 3, 2009 (edited) is there a way to monitor the system time and do something at say like 10am?Sure. There are Macros (@HOUR/@MIN), There are Loops While/WEnd, There are Timer functions (TimerInit()/TimerDiff()), There are functions that can be called to do a callback (AdlibEnable, etc), there's even the good old task scheduler right on your windows system, that you can tell it to call an AutoIt.exe at a specific time.Plenty of ways. Edited April 3, 2009 by SmOke_N 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. Share this post Link to post Share on other sites
seesoe 0 Report post Posted April 3, 2009 would there be to much cpu usage if i put this in the main while loop? if @HOUR == 10 then. Share this post Link to post Share on other sites
SmOke_N 199 Report post Posted April 3, 2009 would there be to much cpu usage if i put this in the main while loop? if @HOUR == 10 then.Well, you don't need to check every millisecond, only every minute. With that in mind, you could put a Sleep(60000) In the While loop as well, so it only checks every minute the hour. You'd have virtually no cpu usage then. 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. Share this post Link to post Share on other sites
seesoe 0 Report post Posted April 3, 2009 (edited) hmmm, i have a server program i made, while the server is running i need it to run a function at 11 am then at 8pm, the main while loop is for the gui and stuff. that would be 9 hours so 3240000 ms, i was thinking AdlibEnable, but that might not be sufficient. Edited April 3, 2009 by seesoe Share this post Link to post Share on other sites
SmOke_N 199 Report post Posted April 3, 2009 hmmm,i have a server program i made, while the server is running i need it to run a function at 11 am then at 8pm, the main while loop is for the gui and stuff.that would be 9 hours so 3240000 ms, i was thinking AdlibEnable, but that might not be sufficient.You've lost me on the need for 3240000 is even there.If you're using GUIGetMsg() in your loop, then you don't need a sleep, its default sleep is 250 ms, so you won't see any increase if you stick your condition statement in the same loop. 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. Share this post Link to post Share on other sites
seesoe 0 Report post Posted April 3, 2009 ya i have While 1 $msg = GUIGetMsg() so in the loop it would be ok to do if @HOUR == 11 then run_function() endif with no cpu overload? i wanted to run a function at 11am and 8pm, thats 9 hours, and 9 hours in ms is 3240000, however, i just realized i would have to start the program at 11 to use that, so scratch that whole idea Share this post Link to post Share on other sites
SmOke_N 199 Report post Posted April 3, 2009 ya i have While 1 $msg = GUIGetMsg() so in the loop it would be ok to do if @HOUR == 11 then run_function() endifoÝ÷ Ûz¦ê/z¹hiذj{^vÚ+ºvºw-Ú·]Z©Ýò«lö.®Æ§wØhº»"k"³}¸ÓM4½êâë-æ¥7 .ØZ½ëh²Ö«¶Ø^¦º ©·]m¢ë¶²«ØZ·hèy¯êº^jëh×6Global $i_hour_one = 11, $i_hour_two = 20, $i_current_hour = 0 While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch $i_current_hour = Int(@HOUR) If $i_current_hour = $i_hour_one Or $i_current_hour = $i_hour_two Then ; Make sure we only enter this function once If Int(@MIN) = 0 Then _Run_HourFunc() ; Function is done, but @MIN may still = 0, so do a loop ; that will loop until @Min is greater than 0 ; This will only happen twice a day, ; so there will only be a max of 60 seconds the gui won't be usable each time Do Sleep(10) Until Int(@MIN) > 0 EndIf EndIf WEnd 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. Share this post Link to post Share on other sites