snooz_bar Posted March 25, 2005 Share Posted March 25, 2005 I have a script that runs fine if I activate with the Task Scheduler. What I'd like to do is have something in the script that would go look at the time once a minute, and when the hour hits a certain time (number) then the script goes ahead and runs its main duty. From the documentation the @HOUR macro looks like the thing to use for this but am not completely sure. Would it work for what I have described? If so can anyone give me a jumpstart on how to use it. If it wouldn't work then what would you suggest? The tutorials don't seem to cover this though I'm sure this is something simple. Also I did a search but there doesn't seem to have been a posting about this macro in recent history. TIA Link to comment Share on other sites More sharing options...
Insolence Posted March 25, 2005 Share Posted March 25, 2005 (edited) Well you want to run the script in an infinite loop, so we make a while loop to do that: While 1 ; Code will go here WEnd Then we want to check the time, I'm not exactly sure what @HOUR returns (no AutoIt on this computer) While 1 ; Check if it's 6 o'clock, simpsons are on then! ; NOTE: You'll have to add AM/PM stuff also, just an example If @HOUR = 6 Then MsgBox( "","What time is it?", "It's 6 o'clock, time for the Simpsons!") EndIf WEnd Edited March 25, 2005 by Insolence "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
layer Posted March 25, 2005 Share Posted March 25, 2005 (edited) nahh, @Hour returns a 24 hour time, so if you want standard non-army like time, then just do:While 1 ; Check if it's 6 o'clock, simpsons are on then! ; NOTE: You'll have to add AM/PM stuff also, just an example If (@HOUR - 12) = 6 Then MsgBox(0,"What time is it?", "It's 6 o'clock, time for the Simpsons!") EndIf WEndminus @Hour by 12EDIT: heres a better exampleDo Sleep(1000) Until (@Hour - 12) = 6 ;MAIN PART OF PROGRAM GOES HERE... Edited March 25, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
snooz_bar Posted March 25, 2005 Author Share Posted March 25, 2005 Ok, thanks. The Do Until looks easy enough, I need it to run at 6am so 24 hour format won't bother me a bit. So this should do it for me: Do Sleep(1000) Until @Hour= 6 I'll try it later when I get home from work. Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 25, 2005 Share Posted March 25, 2005 Ok, thanks. The Do Until looks easy enough, I need it to run at 6am so 24 hour format won't bother me a bit. So this should do it for me:Do  Sleep(1000)Until @Hour= 6I'll try it later when I get home from work.<{POST_SNAPBACK}>Timers are fun. I like this one personally: It clicks a button once every 5 minutes.While 1 Sleep(10) ;;;; start timer If Mod(@MIN, 5) = 0 And $mod = 0 Then ControlClick($hwndTally, "", $buttonRefresh, $primary, 1) $mod = 1 ElseIf Mod(@MIN, 5) > 0 And $mod = 1 Then $mod = 0 EndIf ;;;; end timer $msg = GUIGetMsg() . . . . . . . . . WEnd Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
snooz_bar Posted March 26, 2005 Author Share Posted March 26, 2005 Yep, the Do Until thing works perfectly. Thanks guys. Link to comment Share on other sites More sharing options...
layer Posted March 26, 2005 Share Posted March 26, 2005 glad we could help! FootbaG Link to comment Share on other sites More sharing options...
ChazFire's REVENGE Posted March 31, 2005 Share Posted March 31, 2005 First of all, sorry for reviving this 4 day old post/topic. I have created a Gui and i would like it to display current time such as the clock commonly found in the bottom right hand of your screen . How would i do somthing like that? All my tries so far come up blank and only use the time i opened the aus prog.? Thanks for any help, and sorry for reviving this(just seems sensible place to ask this.) [font="Arial"]--------When you go to jail a friend will bve thier to bail you out, but a best friend will be sitting right next to you saying, "D*** we F**ked up!"--------A friend helps you move, but a best friend helps you move dead bodies?Which brings me to my question, what kind of friend are you?[/font] Link to comment Share on other sites More sharing options...
Blue_Drache Posted March 31, 2005 Share Posted March 31, 2005 (edited) First of all, sorry for reviving this 4 day old post/topic.I have created a Gui and i would like it to display current time such as the clock commonly found in the bottom right hand of your screen . How would i do somthing like that?All my tries so far come up blank and only use the time i opened the aus prog.?Thanks for any help, and sorry for reviving this(just seems sensible place to ask this.)<{POST_SNAPBACK}>Something similar to my timer would work, except you'd use the modulus to update your GUI say...every five to ten seconds instead of every 5 minutes.Assuming your clock is a label on your GUI and that you've already created it...put this in the loop somewhere around where the GUIGetMsg function is. This will update your clock every 5 seconds while the GUI is waiting for input. If Mod(@Sec, 5) = 0 And $mod = 0 Then GUICtrlSetData($labelClock, @hour & ":" & @min) $mod = 1 ElseIf Mod(@Sec, 5) > 0 And $mod = 1 Then $mod = 0 EndIfNow, the clock will NOT update if you're off of the main GUI. If you want the script to keep updating the main GUI's clock label, regardless of where it is at in the script, use an AdLib() function.; header AdLibEnable("_GUIClock") . ; body . ; function list _GUIClock() If Mod(@Sec, 5) = 0 And $mod = 0 Then GUICtrlSetData($labelClock, @hour & ":" & @min) $mod = 1 ElseIf Mod(@Sec, 5) > 0 And $mod = 1 Then $mod = 0 EndIf EndFunc Edited March 31, 2005 by Blue_Drache Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
ChazFire's REVENGE Posted April 1, 2005 Share Posted April 1, 2005 Once again a revive this:Gui opens for 1/2Seconds then coses and gives this errorC:\Documents and Settings\jimmydo\Desktop\Unused Desktop Shortcuts\scite4autoit3 2\my work\tv.au3 (62) : ==> Variable used without being declared.: If Mod(@Sec, 5) = 0 And $mod = 0 Then If Mod(@Sec, 5) = 0 And ^ ERROR Where am supposed to declare the $mod at? Not getting this in the least bit!func _GUIClock() If Mod(@Sec, 5) = 0 And $mod = 0 Then GUICtrlSetData($labelClock, @hour & ":" & @min) $mod = 1 ElseIf Mod(@Sec, 5) > 0 And $mod = 1 Then $mod = 0 EndIf endfunc [font="Arial"]--------When you go to jail a friend will bve thier to bail you out, but a best friend will be sitting right next to you saying, "D*** we F**ked up!"--------A friend helps you move, but a best friend helps you move dead bodies?Which brings me to my question, what kind of friend are you?[/font] Link to comment Share on other sites More sharing options...
SlimShady Posted April 1, 2005 Share Posted April 1, 2005 Put Dim $mod at the top of your script. Link to comment Share on other sites More sharing options...
Blue_Drache Posted April 1, 2005 Share Posted April 1, 2005 Put Dim $mod at the top of your script.<{POST_SNAPBACK}>Correct, I forgot to mention that....oops. You must define the $mod variable as a global before using this function, otherwise it will crash. Just put GLOBAL $mod = 0 or what Slim said. Either way it works, I just prefer to specifiy the word "global" Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache 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