try this in an otherwise empty .bat file:
@echo off
echo Try space and arrow-down
pause
echo 1
pause
echo 2
pause
echo 3
pause
echo 4
pause
echo 5
Why does any of the arrow keys trigger two consecutive pauses, while a space or a letter only triggers one?
Thanks! bers
PAUSE. The most obvious way to pause a batch file is of course the PAUSE command. This will stop execution of the batch file until someone presses "any key". Well, almost any key: Ctrl, Shift, NumLock etc.
When echo is turned off, the command prompt doesn't appear in the Command Prompt window. To display the command prompt again, type echo on. To prevent all commands in a batch file (including the echo off command) from displaying on the screen, on the first line of the batch file type: Copy. @echo off.
Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> ) Required. Specifies one or more files, directories, or text strings, or a range of values on which to run the command.
I suspect pause is simply a call to _getch(), which blocks until it reads a single character of input, but which has the caveat "When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With