Here is a revision of your Update subroutine, it uses standard AHK commands to calculate and format the elapsed time. (also added a couple of useful hotkeys. I tested this code and it works.
Code:
#NoTrayIcon
esc = 1
; GOTO START ; needs to be GoSub
GoSub, START ; like this
GoSub, SHOWTIMER ; add this to show on start up
ESCAPE & F1::GoSub SHOWTIMER
#b::tStart := A_Now ; added hotkey (win+b) to reset elapsed timer to 0
#x::ExitApp ; added hotkey (win+x) to exit script
SHOWTIMER:
if esc = 1
{
Gui, Show, x5 y599 NoActivate
esc = 0
RETURN
}
if esc = 0
{
GUI, Hide
esc = 1
RETURN
}
RETURN
START:
; SetBatchLines, -1 ; this is not useful for anything in this script
CustomColor = 000000
Gui +LastFound +AlwaysOnBottom -Caption +ToolWindow
Gui, Color, %CustomColor%
Gui, Font, s20
Gui, Add, Text, vMyText cWhite, XXXXX, YYYYY
WinSet, TransColor, %CustomColor% 250
tStart := A_Now ; save script start time for future elapsed time calculation
SetTimer, Update, 200 ; makes for smoother display update
Gosub, Update
;Gui, Show, x5 y599 NoActivate
RETURN
Update:
if !(tNow = A_Now) { ; if time has not changes, return
tTemp := tNow := A_Now
EnvSub, tTemp, tStart, seconds ; calculate # of seconds since script start
tdummy = 20000101
EnvAdd, tdummy, tTemp, seconds ; add # of seconds to dummy date/time
FormatTime, elapsed, %tdummy%, HH:mm:ss ; only show hour, minutes, seconds
GuiControl,, MyText, %elapsed%
}
RETURN