如何在不实际打开大写锁定的情况下打开键盘的大写锁定灯? [英] Way to turn on keyboard's caps-lock light without actually turning on caps-lock?

查看:218
本文介绍了如何在不实际打开大写锁定的情况下打开键盘的大写锁定灯?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个使用大写锁定作为拨动开关的程序.设置键的LED来显示我的程序是打开还是关闭,就像Capslock键自然起作用一样.

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 capslock key does naturally.

我知道我可以按SendInput('Capslock');或任何实际打开和关闭大写锁定的功能.但是我的应用程序是一个打字程序,我不需要处理翻译全大写字母的键,只要打开它们就可以将我变成大写或小写字母.我可能最终会走那条路,但不是这个版本.

I know that I could just SendInput('Capslock'); or whatever to actually turn caps-lock on and off. But my app 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.

但是我只想打开LED灯,而实际上没有打开大写锁定.有什么办法吗?

I would however be interested in just turning on the LED light WITHOUT actually turning on caps-lock. Is there any way to do that?

谢谢.

推荐答案

Miranda IM的插件名为"

There are plugin for Miranda IM named "Keyboard Notify Ext." which contains in its source code C implementation of controlling leds. See file keyboard.c in source. Probably you can port it to C#.

以下是源代码中最有趣的亮点:

Here are most interesting highlights from source code:

mir_snprintf(aux1, sizeof(aux1), "Kbd%d", i);
mir_snprintf(aux2, sizeof(aux2), "\\Device\\KeyboardClass%d", i);
DefineDosDevice(DDD_RAW_TARGET_PATH, aux1, aux2);

mir_snprintf(aux1, sizeof(aux1), "\\\\.\\Kbd%d", i);
hKbdDev[i] = CreateFile(aux1, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

...

result |= DeviceIoControl(hKbdDev[i], IOCTL_KEYBOARD_SET_INDICATORS, &InputBuffer, DataLength, NULL, 0, &ReturnedLength, NULL);

这篇关于如何在不实际打开大写锁定的情况下打开键盘的大写锁定灯?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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