Question About Keyboard Input

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Question About Keyboard Input

#1 Post by alleypuppy » 19 Jun 2011 10:14

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!
Last edited by alleypuppy on 19 Jun 2011 10:26, edited 1 time in total.

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Question About Keyboard Input

#2 Post by Ed Dyreen » 19 Jun 2011 10:21

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...

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Question About Keyboard Input

#3 Post by alleypuppy » 19 Jun 2011 10:25

The ASCII Character Set defines ^C as being "End of Text", which I guess is the same as "goto :eof"

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Question About Keyboard Input

#4 Post by Ed Dyreen » 19 Jun 2011 10:55


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...
Last edited by Ed Dyreen on 19 Jun 2011 11:08, edited 2 times in total.

alleypuppy
Posts: 82
Joined: 24 Apr 2011 19:20

Re: Question About Keyboard Input

#5 Post by alleypuppy » 19 Jun 2011 11:02

No it didn't seem to work. :(

orange_batch
Expert
Posts: 442
Joined: 01 Aug 2010 17:13
Location: Canadian Pacific
Contact:

Re: Question About Keyboard Input

#6 Post by orange_batch » 19 Jun 2011 20:51

You can program a routine that involves set /p to do this. 8)

scienceguru1.bat
Posts: 44
Joined: 01 Jan 2011 20:54

Re: Question About Keyboard Input

#7 Post by scienceguru1.bat » 24 Jun 2011 20:36

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~

Ed Dyreen
Expert
Posts: 1569
Joined: 16 May 2011 08:21
Location: Flanders(Belgium)
Contact:

Re: Question About Keyboard Input

#8 Post by Ed Dyreen » 29 Jun 2011 13:44


@orange
%@echon%

another time it says:

%@nechon%

fix either and it might work
This time I agree :wink:

Code: Select all

set "@echon=echo("
set "@nechon=%@echon% &%@echon%"
I'm sorry for posting you incomplete code @alley :oops:

@orange
You can program a routine that involves set /p to do this. 8)
So how would you code set /p so it resumes on any key, it won't support timouts though :|

Post Reply