Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
#include <GUIConstantsEx.au3>
$Form1_1 = GUICreate("Stopwatch", 170, 70);, 100, 100)
$LapsedTime = GUICtrlCreateLabel(" 00:00:00.0", 10, 10, 200, 25)
GUICtrlSetTip(-1, "Lapsed time")
GUICtrlSetFont(-1, 18)
$Button1 = GUICtrlCreateButton("halt/go", 10, 40, 50, 20) ; go / pause
GUICtrlSetTip(-1, "Pause/Unpause counting")
$Button2 = GUICtrlCreateButton("clear", 60, 40, 50, 20) ; reset
GUICtrlSetTip(-1, "Clears counter and stops")
$Button3 = GUICtrlCreateButton("restart", 110, 40, 50, 20) ; restart
GUICtrlSetTip(-1, "Clears counter and restarts")
GUISetState(@SW_SHOW)
Stopwatch(2) ; reset to 0 and stops
While 1
$x = Int(Stopwatch() / 100)
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1 ; toggle status (go <-> pause)
Stopwatch() ; this reads counter and sets @extended according to actual $paused status
Stopwatch(@extended) ; if is paused (@extended = 1) then unpause [Stopwatch(1)]
; if is unpaused (@extended = 0) then pause [Stopwatch(0)]
Case $Button2 ; reset to 0 and stop counter
Stopwatch(2)
Case $Button3 ; reset to 0 and restart counter
Stopwatch(3)
EndSwitch
If $x <> Int(Stopwatch() / 100) Then
$totsec = Int(Stopwatch() / 1000) ; ms to sec
$hr = Int($totsec / 3600) ; hours
$mn = Int(($totsec - ($hr * 3600)) / 60) ; minutes
$sc = Int(($totsec - ($hr * 3600) - ($mn * 60))) ; seconds
$tn = Int((Int(Stopwatch() / 100) - ($hr * 36000) - ($mn * 600) - ($sc * 10))) ; tenths of a second
GUICtrlSetData($LapsedTime, " " & StringFormat("%02s", $hr) & ":" & StringFormat("%02s", $mn) & ":" & StringFormat("%02s", $sc) & "." & StringFormat("%01s", $tn))
EndIf
WEnd
; --- end of example ---
; #FUNCTION# (snippet) ==========================================================================================================
; Name...........: Stopwatch
; Description ...: returns the number of milliseconds counted (according to actions requests by caller)
; Syntax.........: Stopwatch([$action])
; Parameters ....: $action: 0 - pause counting
; 1 - resume counting
; 2 - reset counter to 0 and stops
; 3 - reset counter to 0 and start counting
; 4 - (default) just ruturns actual counting value and status (status in @extended)
;
; Return values .: number of milliseconds in counter
; @extended contains paused status (1 or 0)
; 1 if stopwatch is in pause
; 0 if stopwatch is counting
;
; Author ........:
; Modified.......:
; Remarks .......:
; Related .......:
; Link ..........:
; Example .......: yes
; ===============================================================================================================================
Func Stopwatch($ToggleTo = 4)
Static Local $Paused = True
Static Local $Stopwatch = 0
Static Local $TotalTime = 0
Switch $ToggleTo
Case 0 ; pause counter
If $Paused Then
SetExtended($Paused) ; $Paused status
Return $TotalTime ; already paused, just return current $TotalTime
Else
$TotalTime += TimerDiff($Stopwatch)
$Paused = True
SetExtended($Paused)
Return $TotalTime
EndIf
Case 1 ; unpause counter
If $Paused Then
$Stopwatch = TimerInit()
$Paused = False
SetExtended($Paused)
Return $TotalTime
Else
SetExtended($Paused)
Return $TotalTime + TimerDiff($Stopwatch)
EndIf
Case 2 ; reset to 0 and pause
$Paused = True
$TotalTime = 0
SetExtended($Paused)
Return $TotalTime
Case 3 ; reset to 0 and restart
$Paused = False
$TotalTime = 0
$Stopwatch = TimerInit()
SetExtended($Paused)
Return $TotalTime
Case 4 ; return status
SetExtended($Paused)
If $Paused Then
Return $TotalTime
Else
Return $TotalTime + TimerDiff($Stopwatch)
EndIf
EndSwitch
EndFunc ;==>Stopwatch
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team