kistoff Posted July 27, 2010 Share Posted July 27, 2010 This is not my code, but I wanted this timer to count in minutes. I have found explanations on the forum on how to do it, but unfortunately iv been trying to figure out how to add it into the script and can not get it to work. I want the count to display in minutes:seconds for example 1:30 would be 1min 30sec rather then it counting up to 100 and continuing. I have the code I found for getting minutes and seconds at the bottom, but I have not been able to figure out a way to get it to work in the script. expandcollapse popupHotKeySet("{NUMPADADD}","Start_timer") HotKeySet("{NUMPADSUB}","Pause_timer") HotKeySet("{NUMPADMULT}","Resume_timer") Global $PausedTimer Global $Init0 while 1 WEnd ; A. The function that starts the stopwatch Func start_timer() $Init0 = TimerInit() AdlibRegister("show_timer",60) EndFunc ; B. The function that pauses the stopwatch Func pause_timer() AdlibUnRegister() $PausedTimer = TimerInit() EndFunc ; A. The function that resumes the stopwatch Func resume_timer() AdlibRegister("show_timer",60) $Init0 = $Init0 + TimerDiff($PausedTimer) * 3600 EndFunc Func show_timer() ToolTip("Count = " & Floor(TimerDiff($Init0)/1000), 0, 0, "Timer") EndFunc ;~ $Minutes1 = int($sec / 60) ;~ $Minutes = int(mod ($Minutes1, 60)) ;~ If $Minutes < 10 Then $Minutes = "0" & $Minutes ;~ $Hours = int(int($sec) / 3600) ;~ If $Hours < 10 Then $Hours = "0" & $Hours Link to comment Share on other sites More sharing options...
smashly Posted July 27, 2010 Share Posted July 27, 2010 (edited) Hi, maybe you could use _TicksToTime() and StringFormat() to get the time to display as you need.expandcollapse popup#include <Date.au3> ; used for _TicksToTime() HotKeySet("{ESC}", "Quit") ; to exit HotKeySet("{NUMPADADD}", "start_timer") ; Start or Reset timer ;Set and unset Pause and Resume hotkeys, eliminates multi pressing of pause or resume. Global $Init0, $PausedTimer, $iHours, $iMins, $iSecs While 1 Sleep(10) ; Small sleep to lower cpu usage WEnd ; The function that starts or resets the stopwatch Func start_timer() HotKeySet("{NUMPADMULT}") ;disable resume timer HotKeySet("{NUMPADSUB}", "pause_timer") ;enable pause timer $PausedTimer = 0 $Init0 = TimerInit() AdlibRegister("show_timer", 60) EndFunc ;==>start_timer ; The function that pauses the stopwatch Func pause_timer() HotKeySet("{NUMPADSUB}") ;disable pause timer HotKeySet("{NUMPADMULT}", "resume_timer") ;enable resume timer $PausedTimer += Int(TimerDiff($Init0)) AdlibUnRegister() EndFunc ;==>pause_timer ; The function that resumes the stopwatch Func resume_timer() HotKeySet("{NUMPADMULT}") ;disable resume timer HotKeySet("{NUMPADSUB}", "pause_timer") ;enable pause timer $Init0 = TimerInit() AdlibRegister("show_timer", 60) EndFunc ;==>resume_timer Func show_timer() ; _TicksToTime to get hours, mins, seconds _TicksToTime(Int(TimerDiff($Init0) + $PausedTimer), $iHours, $iMins, $iSecs) ;StringFormat to display the time as HH:MM:SS ToolTip("HH:MM:SS = " & StringFormat("%02i:%02i:%02i", $iHours, $iMins, $iSecs), 0, 0, "Timer") EndFunc ;==>show_timer ; Exit Func Quit() Exit EndFunc ;==>Quit Cheers Edited July 27, 2010 by smashly Autolaser 1 Link to comment Share on other sites More sharing options...
kistoff Posted July 27, 2010 Author Share Posted July 27, 2010 This works really well thanks! Now to try and understand it all hehe. 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