批处理文件,用于检测击键.如何? [英] batch file that detects keystrokes. how?

查看:89
本文介绍了批处理文件,用于检测击键.如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为命令行设计了一系列视频游戏(例如,不交易或不交易,井字游戏,赛车,迷宫拼图,四人连接,w鼠等),但这确实会让我更轻松如果我可以做到,那么当用户做出选择时(例如,游戏中要朝哪个方向移动),只要他们按下箭头键,它就会执行随后的IF语句.不必在每次选择后都按Enter键.像...

:one1
set /p direction1= :
IF %direction1%== {ARROW KEY LEFT} goto two2
IF %direction1%== {ARROW KEY RIGHT} goto three3
IF %direction1%== {ARROW KEY UP} goto four4
IF %direction1%== {ARROW KEY DOWN} goto five5
goto one1

有什么想法吗?

解决方案

:start

choice /c:HPKM /n "Move with arrow keys"

if "%errorlevel%"=="1" {COMMAND}

if "%errorlevel%"=="2" {COMMAND}

if "%errorlevel%"=="3" {COMMAND}

if "%errorlevel%"=="4" {COMMAND}

im designing a collection of video games for the command line (such as deal or no deal, tic tac toe, racing, maze puzzle, connect four, wack a mole, etc.) however it would really make things easier for me if i could make it so that when the user makes a selection (such as what direction to move in the game) , that as soon as they press the arrow keys then it carries out the IF statements that follow. Instead of having to press enter after each selection. something like...

:one1
set /p direction1= :
IF %direction1%== {ARROW KEY LEFT} goto two2
IF %direction1%== {ARROW KEY RIGHT} goto three3
IF %direction1%== {ARROW KEY UP} goto four4
IF %direction1%== {ARROW KEY DOWN} goto five5
goto one1

Any Ideas?

解决方案

:start

choice /c:HPKM /n "Move with arrow keys"

if "%errorlevel%"=="1" {COMMAND}

if "%errorlevel%"=="2" {COMMAND}

if "%errorlevel%"=="3" {COMMAND}

if "%errorlevel%"=="4" {COMMAND}

这篇关于批处理文件,用于检测击键.如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆