Meesterlijk Posted March 7, 2015 Share Posted March 7, 2015 (edited) Hi people, I've been searching how to solve my problem on the forum but nothing i've tried helped me. My problem: When i pause my script after (lets say) 5 secs, the time stops. But when i resume, the time cycle starts all over from the beginning instead if continuing from where it stopped? I know i have to load the paused time in memory to use it again when i resume, but how? Could someone please give me a push in the right direction. Here is my script: expandcollapse popup#include <Date.au3> Global $TimeToSpend = 30000 ;30 secs. Global $Pause = 0 HotKeySet("{PAUSE}", "_TogglePause") HotKeySet("{ESC}", "_Exit") Local $Timer = TimerInit() While 1 Sleep(1000) Local $TimeDiff = TimerDiff($Timer) ;Returns the difference in time from a previous call to TimerInit(). Local $TimeLeft = $TimeToSpend - $TimeDiff Local $hour, $min, $sec, $beep, $pos if $TimeDiff >= $TimeToSpend Then ;Time is up! exit Else Local $Tooltip_Info = "Time left: " $pos = StringLen($Tooltip_Info) ToolTip($Tooltip_Info & _ConvertRunningTime($TimeLeft), @DesktopWidth - ($pos * 20), 0) EndIf WEnd Func _TogglePause() If $Pause = 0 Then $TimeLeft = $TimeToSpend - $TimeDiff ;Backup the time for later use... $Pause = 1 $Message = "Countdown is paused by user !" & @LF _ & "Click ""Pause break"" to continue" $Splash = SplashTextOn("Paused", $Message, 380, 90, -1, -1, 4, "", 20) $Coords = WinGetPos($Splash) While $Pause Sleep(500) ;Start some code WEnd SplashOff() ;Turns SplashText or SplashImage off. Else $Timer = TimerInit() $Pause = 0 EndIf EndFunc ;==> _TogglePause Func _Exit() Exit EndFunc ;==> _Exit Func _ConvertRunningTime($ms) Local $hour, $min, $sec, $beep _TicksToTime($ms, $hour, $min, $sec) If $hour > 24 Then $hour = Mod($hour, 24) EndIf If $hour = 0 And $min <= 5 And $sec = 0 Then ;When 5 minutes left, play ringout.wav every [60 secs]. If TimerDiff($beep) > 60000 Then ;60000 = Interval time between beebs [1 min.]. SoundPlay(@WindowsDir & "\media\ringout.wav", 0) $beep = TimerInit() EndIf EndIf Return StringFormat("%02i:%02i:%02i", $hour, $min, $sec) EndFunc ;==> _ConvertRunningTime Edited March 7, 2015 by Meesterlijk Link to comment Share on other sites More sharing options...
Solution jguinch Posted March 7, 2015 Solution Share Posted March 7, 2015 You can just to that : Else $TimeToSpend = $TimeLeft $Timer = TimerInit() $Pause = 0 EndIf zalomalo 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Meesterlijk Posted March 7, 2015 Author Share Posted March 7, 2015 (edited) @jguinch Thanks in a Million!! Sometimes it seems a simple thing. Thanks m8 This one is solved! Edited March 7, 2015 by Meesterlijk Link to comment Share on other sites More sharing options...
jguinch Posted March 7, 2015 Share Posted March 7, 2015 You're welcome. So you can mark the post as solved... Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF 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