; -------------------
; Set up environment.
; -------------------
; -------------------------
; Set any needed variables.
; -------------------------
myCounter := 0
Allow_Counter_Update := True
; -------------
; Build out GUI
; -------------
Gui, Add, Text , xm ym w200 h100 0x1200 Center vCounter_txt
, % myCounter
Gui, Add, Button, xm
+105 ym
+105 w95 h25 vMinus_btn gOnButton
, -1
SetTimer, OnHour
, 1000 ; Fire every second.
Return ; End of auto-execute section.
{
}
Return
OnButton:
{
{
DoCounter( "Up" )
}
{
DoCounter( "Down" )
}
}
Return
OnHour:
{
If ( Mod( myNow
, 100 ) = 0 ) ; We're at the top of an hour. {
If ( Allow_Counter_Update = True )
{
; Increase counter by one and then don't allow any more
; increases until the minute is up. Otherwise, the
; counter would increase by one every second.
DoCounter( "Up" )
Allow_Counter_Update := False
}
}
; We are no longer in a top-of-the-hour minute so allow
; updates again for the next top-of-the-hour minute.
If ( Mod( myNow
, 100 ) !
= 0 ) {
Allow_Counter_Update := True
}
}
Return
DoCounter( sWay )
{
Global
If ( sWay = "Up" )
{
myCounter++
}
Else If ( sWay = "Down" )
{
myCounter--
}
}