简体   繁体   English

大写锁定切换批处理文件?

[英]Caps Lock Toggle in Batch File?

I am writing a batch file program which utilises the choice command like so: 我正在编写一个使用choice命令的批处理文件程序,如下所示:

choice /C Xx /N /CS

Don't fret about the /M switch, or the /T and /D switch pair, I just want to fool-proof this program so that a user can not accidentally, due to being unaware of the Caps Lock state, make the wrong choice. 不要为/ M开关或/ T和/ D开关对感到烦恼,我只是想对这个程序进行防呆,以使用户不会因为未意识到Caps Lock状态而意外地犯错了选择。 I have read numerous articles, on the Microsoft site, here at SO, and other external internet sources, that provide batch file solutions, but all of these solutions have involved some sort of external program, like a VBS script or the like. 我已经在Microsoft网站(位于SO上)和其他外部Internet来源阅读了许多文章,这些文章提供了批处理文件解决方案,但是所有这些解决方案都涉及某种外部程序,例如VBS脚本等。 I don't mind being referred to an external source, or another question on SO if it meets my needs. 我不介意将其转给外部资源,或者是否满足我的需求而提出其他问题。

In short, I would like to be able to toggle Caps Lock in pure batch , without using anything except batch file. 简而言之,我希望能够以纯批处理方式切换Caps Lock,而不使用批处理文件以外的任何文件。 Thanks in advance. 提前致谢。

You can't - Windows BAT/CMD script language does not have a way to do so. 您不能-Windows BAT / CMD脚本语言没有办法。 Complete list of statements/command directly supported by CMD is available on TechNet:CMD . TechNet:CMD上提供了CMD直接支持的语句/命令的完整列表。 Note that even choice you are using is not part of the script language itself. 请注意,即使您使用的choice也不是脚本语言本身的一部分。

As pointed in comments removing "/CS" option will do case insensitive comparison you are looking for: 如注释中所指出的,删除“ / CS”选项将进行不区分大小写的比较:

choice /? 选择 /?
... ...
/CS Enables case-sensitive choices to be selected. / CS启用区分大小写的选择。 By default, the utility is case-insensitive. 默认情况下,该实用程序不区分大小写。

Unless you are targeting very old (I think 3.1 or maybe vanilla 95) version of Windows you can safely use VBS as it is always present on more recent versions as well as JavaScript. 除非您针对的是非常旧的Windows版本(我认为是3.1或Vanilla 95),否则您可以安全地使用VBS,因为它始终存在于较新的版本以及JavaScript中。 If you are looking for additional command line utilities check out XP command line reference as it will give you most broadly available list of tools. 如果您正在寻找其他命令行实用程序,请查阅XP命令行参考,因为它会为您提供最广泛的工具列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM