Page 1 of 1
Question About Keyboard Input
Posted: 19 Jun 2011 10:14
by alleypuppy
Hey guys,
Is it possible to add something similar to the "pause" command, but instead of being able to press any key to continue, the user must press "Enter" to continue? Or is there a way to quit the batch file by pressing "Esc" or some key combination other than "Ctrl+C"? Thanks for any help!
Re: Question About Keyboard Input
Posted: 19 Jun 2011 10:21
by Ed Dyreen
CTRL+C, I believe this is the old BREAK is ON command.
I use choice to wait for keypress, this allows timeouts, I'm looking for an ANY key solution aswell...
Re: Question About Keyboard Input
Posted: 19 Jun 2011 10:25
by alleypuppy
The ASCII Character Set defines ^C as being "End of Text", which I guess is the same as "goto :eof"
Re: Question About Keyboard Input
Posted: 19 Jun 2011 10:55
by Ed Dyreen
☺
hey alley, can you test if choice accept ascii 13 as input ?
I believe that ascii 13 is the Carriage Return <ENTER> key.
You create this key like this...
Code: Select all
::--------------------------------------------------------------------------------------------------------------------------
%@Pre% $CR, &%@echon%use only with DelayedExpansion
::(
for /f %%a in ('copy /Z "%~dpf0" nul') do set "$CR=%%a"
::
%@nechon% This is erased!$CR! This Works .
::)
%@Post% $CR use only with DelayedExpansion [OK]
::--------------------------------------------------------------------------------------------------------------------------
I can't test it now
This probably wont work
Set defines ^C as being "End of Text", which I guess is the same as "goto :eof"
It must be inserted as a literal or escaped character, just guessing...
It should be possible, I'm getting back to this...
Re: Question About Keyboard Input
Posted: 19 Jun 2011 11:02
by alleypuppy
No it didn't seem to work.
Re: Question About Keyboard Input
Posted: 19 Jun 2011 20:51
by orange_batch
You can program a routine that involves set /p to do this.
Re: Question About Keyboard Input
Posted: 24 Jun 2011 20:36
by scienceguru1.bat
here might be the error in ed's code:
on time it says:
%@echon%
another time it says:
%@nechon%
fix either and it might work
~C~
Re: Question About Keyboard Input
Posted: 29 Jun 2011 13:44
by Ed Dyreen
☺
@orange
%@echon%
another time it says:
%@nechon%
fix either and it might work
This time I agree
Code: Select all
set "@echon=echo("
set "@nechon=%@echon% &%@echon%"
I'm sorry for posting you incomplete code @alley
@orange
You can program a routine that involves set /p to do this.
So how would you code set /p so it resumes on any key, it won't support timouts though