shay Posted September 7, 2009 Share Posted September 7, 2009 Hi all i have a simple script that sleep for long time (up to 12h)than preform action, i like to add a display for the counter so i`ll see the sleep time, i didn't find any way to display the sleep time. any idea? "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
WolfWorld Posted September 7, 2009 Share Posted September 7, 2009 Hi all i have a simple script that sleep for long time (up to 12h)than preform action, i like to add a display for the counter so i`ll see the sleep time, i didn't find any way to display the sleep time. any idea? $begin = TimerInit() ;Do your waitting here while 1 ; loop $dif = TimerDiff($begin) ; check the time, display it. wend MsgBox(0,"Time Difference",$dif);Now this is the end of the script. Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
jvanegmond Posted September 7, 2009 Share Posted September 7, 2009 $begin = TimerInit() ;Do your waitting here while 1 ; loop $dif = TimerDiff($begin) ; check the time, display it. wend MsgBox(0,"Time Difference",$dif);Now this is the end of the script. PuppyPlanet was trying to make a quick score again and totally fucked up on the example. As for the actual answer to the question, you can use something like this: ; Calls the sleep and display function with a 5 second delay _SleepAndDisplay(5000) Func _SleepAndDisplay($sleepTime, $checkEveryMS = 100) ; $sleepTime determines how long to sleep, $checkEveryMS determines how often should be checked (in example: 100ms checks 10 times per second (1000/100 = 10)) $timeStamp = TimerInit() ; Store the time we started to sleep in a variable while 1 ; Continously check how much time has elapsed and display it $timeDiff = TimerDiff($timeStamp) ; Check how much time has elapsed since we started sleeping if ($timeDiff > $sleepTime) Then ; If the time for sleeping has passed, we can go out of the loop ExitLoop ; Exit the loop and go to the end of the function EndIf ToolTip(@ScriptName & ": " & Round($timeDiff/1000) & "s of waiting have elapsed.", 0, 0) ; Displays a message with the time that has been waited in seconds Sleep($checkEveryMS) ; Wait a while before we do the next step. If we omit this step then CPU message will skyrocket. wend ToolTip("") ; Removes the ToolTip from the screen. Return ; Exits the function EndFunc github.com/jvanegmond Link to comment Share on other sites More sharing options...
WolfWorld Posted September 7, 2009 Share Posted September 7, 2009 (edited) PuppyPlanet was trying to make a quick score again and totally fucked up on the example. As for the actual answer to the question, you can use something like this: ; Calls the sleep and display function with a 5 second delay _SleepAndDisplay(5000) Func _SleepAndDisplay($sleepTime, $checkEveryMS = 100) ; $sleepTime determines how long to sleep, $checkEveryMS determines how often should be checked (in example: 100ms checks 10 times per second (1000/100 = 10)) $timeStamp = TimerInit() ; Store the time we started to sleep in a variable while 1 ; Continously check how much time has elapsed and display it $timeDiff = TimerDiff($timeStamp) ; Check how much time has elapsed since we started sleeping if ($timeDiff > $sleepTime) Then ; If the time for sleeping has passed, we can go out of the loop ExitLoop ; Exit the loop and go to the end of the function EndIf ToolTip(@ScriptName & ": " & Round($timeDiff/1000) & "s of waiting have elapsed.", 0, 0) ; Displays a message with the time that has been waited in seconds Sleep($checkEveryMS) ; Wait a while before we do the next step. If we omit this step then CPU message will skyrocket. wend ToolTip("") ; Removes the ToolTip from the screen. Return ; Exits the function EndFunc Okay, I am going if you don't want me here, bye everyone. Ban me. Do what ever you want just can't stand your f-ing face anymore. OUT! Edit: My last word is. The only reason that you write this script is because I posted a bad script and you just want to call me a PuppyPlanet. You mom is one go and have a look. Edited September 7, 2009 by WolfWorld Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets! Link to comment Share on other sites More sharing options...
shay Posted September 7, 2009 Author Share Posted September 7, 2009 As for the actual answer to the question, you can use something like this: wow this is cool use for the "ToolTip" function,i`ll embedded this in my codethenx you all for the fast replay, "If the facts don't fit the theory, change the facts." Albert Einstein Link to comment Share on other sites More sharing options...
jvanegmond Posted September 7, 2009 Share Posted September 7, 2009 (edited) wow this is cool use for the "ToolTip" function,i`ll embedded this in my codethenx you all for the fast replay,You're more than welcome, shay.If you have any more questions, don't hesitate to ask. Edited September 7, 2009 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
Inverted Posted September 7, 2009 Share Posted September 7, 2009 What is a puppyplanet ?! Link to comment Share on other sites More sharing options...
jvanegmond Posted September 7, 2009 Share Posted September 7, 2009 What is a puppyplanet ?!A variant of the name WolfWorld. github.com/jvanegmond Link to comment Share on other sites More sharing options...
99ojo Posted September 7, 2009 Share Posted September 7, 2009 PuppyPlanet was trying to make a quick score again and totally fucked up on the example. As for the actual answer to the question, you can use something like this: ; Calls the sleep and display function with a 5 second delay _SleepAndDisplay(5000) Func _SleepAndDisplay($sleepTime, $checkEveryMS = 100) ; $sleepTime determines how long to sleep, $checkEveryMS determines how often should be checked (in example: 100ms checks 10 times per second (1000/100 = 10)) $timeStamp = TimerInit() ; Store the time we started to sleep in a variable while 1 ; Continously check how much time has elapsed and display it $timeDiff = TimerDiff($timeStamp) ; Check how much time has elapsed since we started sleeping if ($timeDiff > $sleepTime) Then ; If the time for sleeping has passed, we can go out of the loop ExitLoop ; Exit the loop and go to the end of the function EndIf ToolTip(@ScriptName & ": " & Round($timeDiff/1000) & "s of waiting have elapsed.", 0, 0) ; Displays a message with the time that has been waited in seconds Sleep($checkEveryMS) ; Wait a while before we do the next step. If we omit this step then CPU message will skyrocket. wend ToolTip("") ; Removes the ToolTip from the screen. Return ; Exits the function EndFunc Hi, here's the countdown version: #include <Date.au3> _countDown(50000) Func _countDown($Countdown) $seconds = _DateAdd('s', $Countdown / 1000, _NowCalc()) Do Sleep(100) $sec = _DateDiff('s', _NowCalc(), $seconds) $string = StringFormat("%.02d" & ":" & "%.02d" & ":" & "%.02d", _ Mod($sec / 3600, 24), Mod(($sec / 60), 60), Mod($sec, 60)) ToolTip(@ScriptName & ": Time left before executing: " & $string , 0, 0) Until $sec = 0 EndFunc ;-)) Stefan Link to comment Share on other sites More sharing options...
shay Posted September 7, 2009 Author Share Posted September 7, 2009 Hi,here's the countdown version....;-))StefanThis one is match better to my script!thanks again !!!! Shay "If the facts don't fit the theory, change the facts." Albert Einstein 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