Menu with with GETINPUT.EXE - Problems

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
xuuuul
Posts: 2
Joined: 10 Jan 2021 05:27
Location: Lower Saxony, Germany

Menu with with GETINPUT.EXE - Problems

#1 Post by xuuuul » 11 Jan 2021 13:56

I have found my old batch menu I made in 1997 and updated it for win10.
It works fine with GETINPUT.EXE but when I start non-win-progs by mouse (e.g. clock or clocX) they run twice. When using keyboard everything's okay. Maybe someone can find the bug. . .
It's just for fun so I'm not in a hurry

second bug, maybe an problem in getinput.exe:
After 15 inputs - no matter whether keyboard or mouse input:
"Maximale Rekursionstiefe für SETLOCAL erreicht" (Maximum recursion depth for SETLOCAL reached)

Here*s my batch:

Code: Select all

:START
@echo off
REM CHCP 1252 - codepage wg. Umlauten, aber nur, wenn keine Rahmen!
MODE CON: COLS=79 LINES=17
TITLE Menu Test 2021 01 10
cls

REM Mausunterstützung
setlocal DisableDelayedExpansion
set Ascii= !"#$%%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
setlocal EnableDelayedExpansion
for %%a in ("7=Bell" "8=BackSpc" "9=Tab" "10=LineFeed" "13=Enter" "26=Sub" "27=Esc") do (
for /F "tokens=1,2 delims==" %%b in (%%a) do set "control[%%b]=(%%c)"
)
for %%a in ("33=PageUp" "34=PageDown" "35=End" "36=Home" "37=LeftArrow" "38=UpArrow" "39=RightArrow" "40=DownArrow"
"45=Ins" "46=Del"
"112=F1" "113=F2" "114=F3" "115=F4" "116=F5" "117=F6" "118=F7" "119=F8" "120=F9" "121=F10" "122=F11" "123=F12"
) do (
for /F "tokens=1,2 delims==" %%b in (%%a) do set "extended[%%b]=%%c"
)

echo ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
echo  M E N U E
echo ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
echo.
echo   [ A ] Rechner / calc.exe 
echo   [ B ] ClocX (https://www.freeware.de/download/clocx/) 
echo   [ C ] Clock (https://www.freeware.de/download/analoguhr/) 
echo   [ D ] Software (Entfernen/Hinzufuegen neuer Programme)
echo   [ E ] Software (Windows Komponenten)
echo   [ F ] Hardware
echo   [ G ] Systemsteuerung
echo.
echo   [ Q ] Quit º
echo.
echo ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍXuuuul 2021ͼ

:LOOOP
set input=""
GetInput
set /A "input=%errorlevel%, ctrl=input+32, asc=input-32, alt=input-192, ext=input-256&0xFF"
if %input% gtr 0 goto KEYBOARD
REM if %input% lss 0 echo Mouse button clicked %input% & goto MAUS
if %input% lss 0 goto MAUS
goto LOOOP

:KEYBOARD
if errorlevel 114 goto START
REM kleinbuchstaben
if errorlevel 113 goto Q
if errorlevel 103 goto G
if errorlevel 102 goto F
if errorlevel 101 goto E
if errorlevel 100 goto D
if errorlevel 99 goto C
if errorlevel 98 goto B
if errorlevel 97 goto A
REM GROSSBUCHSTABEN
if errorlevel 81 goto Q
if errorlevel 71 goto G
if errorlevel 70 goto F
if errorlevel 69 goto E
if errorlevel 68 goto D
if errorlevel 67 goto C
if errorlevel 66 goto B
if errorlevel 65 goto A
goto START

:MAUS
REM set /A "input=%errorlevel%, ctrl=input+32, asc=input-32, alt=input-192, ext=input-256&0xFF"
if %input% gtr 0 (
rem Key pressed
set input= %input%
set input=!input:~-3!
if %input% lss 32 (
REM echo !input!: Ctrl-!Ascii:~%ctrl%,1! !control[%input%]!
) else if %input% lss 192 (
REM echo !input!: Ascii: !Ascii:~%asc%,1!
) else if %input% lss 256 (
REM echo !input!: Alt-!Ascii:~%alt%,1!
) else (
if %input% lss 512 (
set extnd= !extended[%ext%]!
) else (
set extnd= Shift-!extended[%ext%]!
)
REM echo !input!: !extnd:~-16!
)
) else ( rem %input% leq 0
rem Mouse button clicked
set /A "input=-input, row=input >> 16, col=input & 0xFFFF"
if !col! lss 32768 (SS
REM echo LEFT @ !row!,!col!
) else (
set /A col-=32768
REM echo @ !row!,!col! RIGHT
)
)

if %input% == 27 goto Q

if %row% == 12 goto Q
if %row% == 10 goto G
if %row% == 9 goto F
if %row% == 8 goto E
if %row% == 7 goto D
if %row% == 6 goto C
if %row% == 5 goto B
if %row% == 4 goto A
goto START

:A
cls
start calc.exe
goto START

:B
cls
cd.\ClocX160
start ClocX.exe
cd..
goto START

:C
cls
start CLOCK.EXE
goto START

:D
rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,0
cls
goto START

:E
rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl,,2
cls
goto START

:F
rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl,,2
cls
goto START

:G
control.exe
cls
goto START

:Q
cls
EXIT
Last edited by aGerman on 12 Jan 2021 13:07, edited 1 time in total.
Reason: code formatting

OJBakker
Expert
Posts: 40
Joined: 12 Aug 2011 13:57

Re: Menu with with GETINPUT.EXE - Problems

#2 Post by OJBakker » 13 Jan 2021 07:49

The 'setlocal' is not hard to explain and easy to solve.
The setlocals and initialization of variables is done every time you return to label :START
So every time you use 2 additional setlocal calls without ending those with endlocal and there is a limit to the maximum available setlocals to use.
Solution: Move the label :START (and cls) after the initialization of variables and just before the echo ... lines.
This way no additional setlocal will be used after the initial 2 and the maximum depth of setlocals will never be reached.

xuuuul
Posts: 2
Joined: 10 Jan 2021 05:27
Location: Lower Saxony, Germany

Re: Menu with with GETINPUT.EXE - Problems

#3 Post by xuuuul » 13 Jan 2021 10:49

Thank you, now it works fine.
Some programs still open twice, maybe it's because of my mouse . . .

Post Reply