在不实际打开大写锁定的情况下打开键盘大写锁定指示灯的方法
我正在编写一个使用 Caps Lock 作为切换开关的程序。如果能设置按键的 LED 来显示我的程序打开或关闭,就像 Caps Lock 键自然所做的那样,那就太好了。
我知道我可以通过 SendInput('Capslock');
或其他任何方式来实际打开和关闭大写锁定。但我的应用程序是一个打字程序,我不想处理翻译全大写键,打开它会让我转换成小写/大写。我最终可能会走这条路,但不是这个版本。
不过,我有兴趣只打开 LED 灯,而不实际打开 Caps Lock。有办法做到这一点吗?
I'm writing a program that uses Caps Lock as a toggle switch. It would be nice to set the LED of the key to show that my program is on or off, like the Caps Lock key does naturally.
I know that I could just SendInput('Capslock');
or whatever to actually turn caps-lock on and off. But my application is a typing program, and I don't want to have to deal with translating the all-caps keys that turning it on would give me into their lower/upper cases. I might go that route eventually, but not for this version.
I would however be interested in just turning on the LED light without actually turning on Caps Lock. Is there a way to do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Miranda IM 有一个名为“Keyboard Notify Ext." 其源代码中包含控制 LED 的 C 实现。请参阅源代码中的文件 keyboard.c。也许您可以将其移植到 C#。
以下是源代码中最有趣的亮点:
There is a plugin for Miranda IM named "Keyboard Notify Ext." which contains in its source code a C implementation of controlling LEDs. See file keyboard.c in the source code. Probably you can port it to C#.
Here are most interesting highlights from source code:
我很确定你不能在不切换实际大写锁定的情况下切换 LED,除非你正在编写键盘驱动程序。 (我不建议这样做!)
I'm pretty sure you can't toggle the LED without toggling the actual caps lock, unless you were writing a keyboard driver. (I'm not recommending that!)
有点晚了,但以防万一其他人偶然发现这一点,这里有一个翻转 Caps Lock LED 的 C# 程序。它基于 @ivanzoid 的答案(以及更多随机的谷歌搜索)。
基本过程是
A bit late to the party, but in case anyone else stumbles across this, here is a C# program flipping the Caps Lock LED. It is based on @ivanzoid's answer (and a lot more random Googling).
The basic procedure is