DoctorSLO Posted January 26, 2009 Share Posted January 26, 2009 Hi. I made some program that do some task at the time that it's entered: I enter like 2 hrs and 0 min, and this is multiplied by 60, 60, 1000 .... so I get sleep time. But what if I want to do more tasks? Like one task for 1 hour and other task for 2 hours ... I can use multiple Sleep(xxx) commands? Or there is another way? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 26, 2009 Moderators Share Posted January 26, 2009 (edited) DoctorSLO, Perhaps the best way to do this is to set an initial timestamp using TimerInit and then use TimerDiff to decide when to run. Pseudo-code would look something like this:Input $time1 Input $time2 $start = TimerInit() While 1 If TimerDiff($start) = $time1 Then Do Task1 If TimerDiff($start) = $time1 Then Do Task2 WEnd Try something like that and ask again if you have a problem. M23 Edited January 26, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
herewasplato Posted January 26, 2009 Share Posted January 26, 2009 see TimerInit and TimerDiff [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
DoctorSLO Posted January 26, 2009 Author Share Posted January 26, 2009 (edited) Hm ... again something new OK, I will try to do it with this ... Thanks for advice Btw. Input cmd doesn't exist ... xD Edited January 26, 2009 by DoctorSLO Link to comment Share on other sites More sharing options...
herewasplato Posted January 26, 2009 Share Posted January 26, 2009 ... Btw. Input cmd doesn't exist ... xDThat is what Pseudo-code means. The code will not detail certain parts of the code that you were not asking about.Input $time1 can represent many different lines of code from a GUI input to a regular InputBox --- all of the error checking and any reformatting of the variable. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
DoctorSLO Posted January 26, 2009 Author Share Posted January 26, 2009 (edited) OK, thx for explain, herewasplato I do some script, but its not work, it sleeps forever .. #Include <Timers.au3> $ena = 10000 $dve = 6000 $Time1 = Sleep($ena) $Time2 = Sleep($dve) $start = TimerInit() While 1 Select Case TimerDiff($start) = $Time1 MsgBox(0, "Time one", "Time ONE") Case TimerDiff($start) = $Time2 MsgBox(0, "Time two", "Time TWO") EndSelect WEnd Exit What I do wrong ? Edited January 26, 2009 by DoctorSLO Link to comment Share on other sites More sharing options...
FireFox Posted January 26, 2009 Share Posted January 26, 2009 (edited) @DoctorSLO $init1 = TimerInit() $init2 = TimerInit() While 1 $diff1 = TimerDiff($init1) $diff2 = TimerDiff($init2) If $init1 >= 1000 then TrayTip('Sleep', 'Slept 1sec !', 0, 1) $init1 = TimerInit() ElseIf $init2 >= 1500 then TrayTip('Sleep', 'Slept 1,5sec !', 0, 1) $init2 = TimerInit() EndIf WEnd Not tested. Cheers, FireFox. Edited January 26, 2009 by FireFox Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2009 Developers Share Posted January 26, 2009 (edited) Not tested.Cheers, FireFox.Maybe you should? I expected a TimerDiff() in there Edited January 26, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
DoctorSLO Posted January 26, 2009 Author Share Posted January 26, 2009 Thx, but this is only showing "Slept 1sec !". its not working Link to comment Share on other sites More sharing options...
DoctorSLO Posted January 26, 2009 Author Share Posted January 26, 2009 Thx, I added TimerDiff() Now look like this: #Include <Timers.au3> $init1 = TimerInit() $init2 = TimerInit() While 1 If TimerDiff($init1) >= 1000 then MsgBox(0, "Time one", "time one") $init1 = TimerInit() ElseIf TimerDiff($init2) >= 1500 then MsgBox(0, "Time two", "Time two") $init2 = TimerInit() EndIf WEnd Exit But script doesn't exit ... when it comes to time two it starts again ... mybe I must use some killtimer cmd or what ? Link to comment Share on other sites More sharing options...
FireFox Posted January 26, 2009 Share Posted January 26, 2009 @Jos thanks i cant test it because im on my ipod @DoctorSLO post edited, try again Link to comment Share on other sites More sharing options...
Developers Jos Posted January 26, 2009 Developers Share Posted January 26, 2009 ExitLoop or Exit depending on what you want to do ? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Aceguy Posted January 26, 2009 Share Posted January 26, 2009 there ya go. Hope you can learn from it $init = TimerInit() While 1 if int(TimerDiff($init)/1000) = 5 then toolTip("Ding!!! 5 Seconds") elseIf int(TimerDiff($init)/1000) = 10 then toolTip("Ding!!! 10 Seconds") ElseIf int(TimerDiff($init)/1000) = 15 then toolTip('Ding!!! 15 seconds') elseif int(TimerDiff($init)/1000) = 20 Then toolTip('') EndIf sleep(250) WEnd [u]My Projects.[/u]Launcher - not just for games & Apps (Mp3's & Network Files)Mp3 File RenamerMy File Backup UtilityFFXI - Realtime to Vana time Clock Link to comment Share on other sites More sharing options...
FireFox Posted January 26, 2009 Share Posted January 26, 2009 @DoctorSLO HotKey example : #Include <Timers.au3> Global $timer = True HotKeySet("{F7}", "_TIMERON") HotKeySet("{F8}", "_TIMEROFF") $init1 = TimerInit() $init2 = TimerInit() While 1 If TimerDiff($init1) >= 1000 and $timer = True then MsgBox(0, "Time one", "time one") $init1 = TimerInit() ElseIf TimerDiff($init2) >= 1500 and $timer = True then MsgBox(0, "Time two", "Time two") $init2 = TimerInit() EndIf WEnd Func _TIMERON() Global $timer = True EndFunc Func _TIMEROFF() Global $timer = False EndFunc Not tested Cheers, FireFox. Link to comment Share on other sites More sharing options...
DoctorSLO Posted January 26, 2009 Author Share Posted January 26, 2009 OK, thx all for help I understand now ... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 26, 2009 Moderators Share Posted January 26, 2009 (edited) DoctorSLO, Apologies for the Pseudo-code misunderstanding. I had to leave for a while - real life gets in the way sometimes! Are you happy with what you have got so far from the others who kindly responded? M23 Edit. I see you are! Edited January 26, 2009 by Melba23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
DoctorSLO Posted January 26, 2009 Author Share Posted January 26, 2009 Melba23, No problem, actually now I know what is Pseudo-code 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