MapVirtualKeyexa带有不同键盘布局
我尝试使用不同的键盘布局使用 mapVirtualKeyexa
。无论我通过哪种键盘layout参数,此功能总是返回英文字母。
我使用控制台应用程序,并通过 getKeyboardLayout
获得布局:
HWND foreground = GetForegroundWindow();
DWORD threadId;
HKL keyboardLayout;
if (foreground)
{
threadId = GetWindowThreadProcessId(foreground, NULL);
keyboardLayout = GetKeyboardLayout(threadId);
}
转换 keycode
to char> char
:
char crrKey;
bool lower = ((GetKeyState(VK_CAPITAL) & 0x0001) != 0);
if ((GetKeyState(VK_SHIFT) & 0x1000) != 0 || (GetKeyState(VK_LSHIFT) & 0x1000) != 0 || (GetKeyState(VK_RSHIFT) & 0x1000) != 0)
{
lower = !lower;
}
crrKey = MapVirtualKeyExA(key, MAPVK_VK_TO_CHAR, keyboardLayout);
cout << keyboardLayout << ": " << crrKey << endl;
if (!lower)
{
crrKey = tolower(crrKey);
}
file << char(crrKey);
我希望在更改更改时语言(Windows + Space)VirtualKey 映射到新语言。我在做什么错?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议您可以使用将指定的虚拟键代码和键盘状态转换为相应的Unicode字符或字符。
I suggest you could use ToUnicodeEx API to translate the specified virtual-key code and keyboard state to the corresponding Unicode character or characters.