检测键盘输入后,窗口识别的关键
Detect keyboard input after windows recognition of the key
我正在构建一个程序,它将在屏幕上打印出按下的按钮的值。我需要它的工作也当程序的窗口不活跃。我尝试使用GetAsyncKeyState(int),它工作得很好。然而,我可以将某些字符串附加到键上,但它不适用于所有类型的键盘(例如,在英语键盘上,shift+2是@,而在我的键盘上则不是)。我如何检测由Windows完成的键输入的后处理(在记事本中书写时在屏幕上打印的字符)?
尝试OemKeyScan函数。对于你的,你应该有扫描码(例如,"2"键有一个给定的扫描码,它总是相同的,取决于键盘上的位置,例如17的"2"键):
int whichscancode= 17;
if (key_with_shift)
whichscancode|= (1<<16); // shifted values with 1<<16
for (i=0; i<256; i++) {
int scan= ::OemKeyScan(i); // try all characters for a matching scancode
if (scan==whichscancode) {
// i here is the ascii code of the key on that position
printf("on that scancode is character %cn", (char)i);
}
}
相关文章:
- 提升 ASIO 无法识别计时器对象
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 从udp接收帧对于人脸识别来说太慢
- 问:如何使用C++中的按钮从窗口打开窗口
- 模板类无法识别友元运算符
- SDL 窗口不会弹出
- 在createdialog创建的窗口中捕获用于编辑控件的OnMouseMove消息
- 如何在cpp文件之间切换窗口?在Qt中
- QuadTree只在窗口的右上角绘制
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- std::visit无法识别类型
- 如何在C++中找到active directory中禁用和锁定的窗口帐户
- 处理闪烁窗口事件
- 仅从 EnumDesktopWindows 识别应用程序窗口
- 如何识别子窗口小部件中的QMouseEvent
- 识别窗口的变体
- 来自文件的窗口语音识别 (SAPI) 的质量
- 如何识别UI窗口以便将其追溯到源代码
- 检测键盘输入后,窗口识别的关键
- 像cerr, exit, string这样的c++表达式在eclipse c++ IDE窗口中无法识别