I am creating a program that needs to countdown seconds. I used the choice command with /t 1 and /d to do that and also need to check if the user pressed any button on the keyboard.
I've got a problem here because I cant pass any non-keyboard character to /d .. so someone could press character from my allchoices string and it will stop counting down.
As far as I know - choice command could operate on a-z, A-Z, 0-9 and ASCII values of 128 to 254, but when I enter ascii like 128 (Ç) i get ERROR: Invalid syntax. /D only accepts single character.
So how could I work around this problem?
This is part of my code:
set /a time = 20
set "if_1=8"
set "if_2=10"
set "if_3=12"
set "allchoices=123456789abcdefghijklmnopqrstuvwxyz"
:loop
cls
echo press 1 for %if_1% Threads
echo press 2 for %if_2% Threads
echo press 3 for %if_3% Threads
echo press any other number key to exit
echo.
echo Countdown - [%time%]
if %time%==0 goto launch
choice /t 1 /c %allchoices% /d z >nul
if %errorlevel% EQU 35 goto dec
if %errorlevel% EQU 1 goto 1
if %errorlevel% EQU 2 goto 2
if %errorlevel% EQU 3 goto 3
if %errorlevel% GEQ 4 goto end
:dec
set /a time = %time%-1
goto loop
and this is what I'm talking about:
set "allchoices=123456789abcdefghijklmnopqrstuvwxyzÇ"
choice /t 1 /c %allchoices% /d Ç >nul
if %errorlevel% EQU 36 goto dec