Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Esc in a Batch File

2,473 views
Skip to first unread message

kun...@rocketmail.com

unread,
Aug 21, 1997, 3:00:00 AM8/21/97
to

Hello :
I am trying to write a batch file that can recognize
"esc" key press. Can someone suggest me how I can accomplish
this task. I have tried using a hex editor to edit
ascii equivalent of "ESC" did not work.

Thanks in advance

Kundurs

-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet

Michael Donn

unread,
Aug 22, 1997, 3:00:00 AM8/22/97
to


This is a surprisingly easy thing to do when using the CHOICE command. The
batchfile copied below will ask for one of the numeric characters, echo
whatever is entered, and ask for more until the esc key is entered. The
"$" stands for the escape character, which must be entered by you. To
enter it with DOS EDIT, press CTRL-P, ESC.

@echo off
cls
:loop
echo.
echo.
echo Enter a number 0 - 9. To terminate, press ESC.
choice /n /c0123456789$ >nul
:: ^
:: ESC
cls
if errorlevel 1 if not errorlevel 2 echo You pressed 0.
if errorlevel 2 if not errorlevel 3 echo You pressed 1.
if errorlevel 3 if not errorlevel 4 echo You pressed 2.
if errorlevel 4 if not errorlevel 5 echo You pressed 3.
if errorlevel 5 if not errorlevel 6 echo You pressed 4.
if errorlevel 6 if not errorlevel 7 echo You pressed 5.
if errorlevel 7 if not errorlevel 8 echo You pressed 6.
if errorlevel 8 if not errorlevel 9 echo You pressed 7.
if errorlevel 9 if not errorlevel 10 echo You pressed 8.
if errorlevel 10 if not errorlevel 11 echo You pressed 9.
if not errorlevel 11 goto loop
:end
set !R!=
cls
echo.
echo.
echo goodbye

NO-...@no_spam.com

unread,
Aug 23, 1997, 3:00:00 AM8/23/97
to

I tried this under win95. It does not recognize the ESC key. and
ctrl-p,ESC causes the following message:

write fault error writing device PRN
Abort, Retry?

NO-...@no_spam.com

unread,
Aug 23, 1997, 3:00:00 AM8/23/97
to
> You seem not to have understood that you have to be in a text editor. The
> "ctrl-p, esc" is the method for entering an ESC while using DOS EDIT. What
> you did was type CTRL-P at the command prompt, which tells dos to echo to
> the printer whatever is typed into the keyboard. Apparently your printer
> was turned off.


My mistake. My dyslexia is overwhelming me. Anyway, to put a twist on
the question, can anyone modify this batch file or write a new one
which, when executed, can recognize "enter" or any other key or other
key-combination such as ctrl-r or F3 key. I suppose it would involve the
ascii character codes. such as:
ctrl-r = 18
F3 = 0;61
enter = ???
But I dont know how to accomplish this.

email: GREENliza...@juno.com (without the GREEN's)

0 new messages