Burgaud Posted May 9, 2014 Posted May 9, 2014 $Clock = TimerInit() ; 3.98 seconds later TimerDiff($Clock) would give me 3980 Is there a way to "Freeze/Pause" $Clock such that TimerDiff() would not increase? ie $Clock = TimerInit() ; 2 seconds later Pause $Clock ;5 seconds later TimerDiff($Clock) would give me 2000 unpause $Clock . . . 3 seconds later TimerDiff($Clock) would give me 5000 Is this possible?
water Posted May 9, 2014 Posted May 9, 2014 No. What do you try to achieve? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
jdelaney Posted May 9, 2014 Posted May 9, 2014 If when you 'pause' you start another time, you can do some subtraction and get the time: HotKeySet("b", "PauseTimer") HotKeySet("c", "escape") $bConsoleWrite = False $PausedCummulative = 0 $bPaused = False $ThePausedTimer = 0 $TheTimer = TimerInit() While True While $bPaused Sleep(100) $bConsoleWrite = True WEnd Sleep(100) If $bConsoleWrite Then $PausedCummulative+=TimerDiff($ThePausedTimer) ConsoleWrite(Round(TimerDiff($TheTimer)/1000,2) & @tab & "-" & Round($PausedCummulative/1000,2) & @tab & "=" & Round((TimerDiff($TheTimer)-$PausedCummulative)/1000,2) & @CRLF ) $bConsoleWrite = False EndIf WEnd Func PauseTimer() $bPaused = Not $bPaused If $bPaused Then $ThePausedTimer = TimerInit() ConsoleWrite("Initiate paused timer" & @CRLF) Else ConsoleWrite("End paused timer" & @CRLF) EndIf EndFunc Func escape() Exit EndFunc IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Gianni Posted May 9, 2014 Posted May 9, 2014 (edited) also AdlibRegister() may be useful... #include <GUIConstantsEx.au3> Global $Paused = True ; True or False Global $MyTimer = 0 ; Actual timer position AdlibRegister("MyTimer", 100) ; function fired every 100 ms $Form1_1 = GUICreate("MyTimer", 120, 70, 100, 100) $seconds = GUICtrlCreateLabel($MyTimer, 10, 10, 80, 25) $Toggle_Button = GUICtrlCreateButton("Toggle timer", 10, 40, 100, 20) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Toggle_Button ToggleTimer() EndSwitch WEnd Func MyTimer() If Not $Paused Then $MyTimer += 0.1 GUICtrlSetData($seconds, $MyTimer) EndIf EndFunc ;==>MyTimer Func ToggleTimer() $Paused = Not $Paused EndFunc ;==>ToggleTimer Edited May 9, 2014 by Chimp Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
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