青春期1赵奕欢在哪能看:批处理中实现无需回车即结束字符输入_共享知识,共同成长

来源:百度文库 编辑:九乡新闻网 时间:2024/04/29 05:52:45
批处理中实现无需回车即结束字符输入2008-09-11 17:12

@echo off
chcp 437>nul
graftabl 936>nul
>tmp.tmp echo e100 B4 01 CD 21 B4 4C CD 21
>>tmp.tmp (echo rcx&echo 8&echo na.com)
>>tmp.tmp (echo w&echo q)
debugdel tmp.tmp
echo                              【 开始按键... 】
:again
ping -n 3 127.1>nul
a.com
echo.
echo           =====▓▓▓▓===== 按键对应ASCII码为 %errorlevel% =====▓▓▓▓=====
if not %errorlevel%==0 goto :again
del a.com

 

输入字符后不等回车即结束输入,类似与pause的效果,但却能将所输入字符的ascii码返回到errorlevel中

增加ping 3秒的作用是证明即使在运行a.com之前的按键依然能够被检测到,这就保证了批处理运行过程中不会出现按键无响应的情况,只是响应的速度取决于调用a.com的频率而已。

按F1~F12键以及Ctrl+C键即可结束批处理。