AutoHotkey scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

85 lines
1.6 KiB

;
; Functions for stopwatch
;
; The stopwatch gui should be called "StopwatchGui",
; and have a text parameter labeled "StopwatchText".
; Window should be initialized in the main script;
; this library assumes the window already exists.
; Global Vars
StopwatchTime = 0
StopwatchHidden = 0
StopwatchOn = 0
SetTimer, StopwatchUpdate, 1000
SetTimer, StopwatchUpdate, Off
StopwatchStop() {
Global StopwatchOn
SetTimer, StopwatchUpdate, Off
StopwatchOn = 0
}
StopwatchStart() {
Global StopwatchOn
SetTimer, StopwatchUpdate, On
StopwatchOn = 1
}
StopwatchToggle() {
Global StopwatchOn
If StopwatchOn {
StopwatchStop()
} Else {
StopwatchStart()
}
}
StopwatchReset() {
Global StopwatchTime
StopwatchTime = 0
StopwatchShow()
}
StopwatchShow() {
Global StopwatchTime, StopwatchHidden
Minutes := Format("{:02}", StopwatchTime // 60)
Seconds := Format("{:02}", Mod(StopwatchTime, 60))
GuiControl, Text, StopwatchText, %Minutes%:%Seconds%
Gui, Show, NoActivate, StopwatchGui
StopwatchHidden = 0
}
StopwatchHide() {
Global StopwatchHidden
StopwatchStop()
Gui, Hide
StopwatchHidden = 1
}
StopwatchToggleHidden() {
Global StopwatchHidden
If StopwatchHidden {
StopwatchShow()
} Else {
StopwatchHide()
}
}
StopwatchUpdate() {
Global StopwatchTime
StopwatchTime++
StopwatchShow()
}
StopwatchFastforward(Seconds:=1) {
Global StopwatchTime
StopwatchTime += Seconds
StopwatchShow()
}
StopwatchRewind(Seconds:=1) {
Global StopwatchTime
StopwatchTime -= Seconds
StopwatchShow()
}