I have been coding a retake of the app “Clock” on phones and it has been going pretty good, I did recently post another question about loops with cls making it flicker and found that <nul set /p "=%E%[H" would move the text cursor to the start and I can echo the next thing on the line to replace it. Resulting in a clean flicker free solution, which for those who pointed out that these kinds of things still work in windows 11, I am extremely grateful.

The question I have now is how can I implement a stopping feature for the stopwatch where it doesn’t effect the timing and when ever the decide to stop it, it will freeze the timer it will still display the time. If you don’t understand my explanation I don’t blame you because I honestly suck at explaining things. In short, code to add the stopping function of a stopwatch. This code below is the stopwatch.

:noTextCursor-stopwatch
set "start_time=%time%"
 For /f %%e in ('Echo Prompt $E^|cmd') Do set "E=%%e"
 <nul Set /P "=%E%[?25l"
 Set /A "delay=4", "Files=0","FC=1"

 For %%i in (5 6 7 8 9 10 11 12 13 14 15 14 13 12 11 10 9 8 7 6 5)Do (
  Set /A Files+=1
  Call :stopwatch %%i "infile!Files!.txt"
 )

 For /L %%i in ()Do (
  for /f "tokens=1-4 delims=:.," %%a in ("!time: =0!") do set /a "t2=(((1%%a*60)+1%%b)*60+1%%c)*100+1%%d-36610100, tDiff=t2-t1"
  if !tDiff! lss 0 set /a tDiff+=24*60*60*100
  if !tDiff! geq !delay! (
   Set /A "FC=FC %% Files + 1"
   <nul Set /P "=%E%[1;0H"
   If !FC! GTR 10 (If !Offset! GTR 1 Set /A "Offset-=1")Else Set "offset=!FC!"
   (For /f "Delims=" %%G in (infile!FC!.txt)Do echo ^[[K%E%[!offset!G%%G%E%[E") > Con
   echo ^[[0J
   set /a t1=t2
  )
 )
 
:stopwatch
<nul set /p "=%E%[H"
set "Timing=0.001"
for /f "tokens=1-4 delims=:.," %%a in ("%start_time%") do (
    set /a "start_h=%%a", "start_m=1%%b-100", "start_s=1%%c-100", "start_ms=1%%d-100"
)
set "end_time=%time%"
for /f "tokens=1-4 delims=:.," %%a in ("%end_time%") do (
    set /a "end_h=%%a", "end_m=1%%b-100", "end_s=1%%c-100", "end_ms=1%%d-100"
)
set /a "elapsed_ms=(end_h*3600000+end_m*60000+end_s*1000+end_ms)-(start_h*3600000+start_m*60000+start_s*1000+start_ms)"

set /a "elapsed_h=elapsed_ms/3600000, elapsed_ms%%=3600000"
set /a "elapsed_m=elapsed_ms/60000, elapsed_ms%%=60000"
set /a "elapsed_s=elapsed_ms/1000, elapsed_ms%%=1000"
set "elapsed_ms=0%elapsed_ms%"
set "elapsed=!elapsed_h!:!elapsed_m!:!elapsed_s!.!elapsed_ms:~-3!"
set "end_time=%time%"

echo %elapsed%
timeout /t !Timing! /nobreak >nul 2>nul

goto stopwatch