如何使用 C++ (keybd_event) 发送 unicode 密钥 [英] How to send unicode keys with c++ (keybd_event)

查看:66
本文介绍了如何使用 C++ (keybd_event) 发送 unicode 密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友正在学习挪威语,我想制作一个全局热键程序,发送诸如

My friend is learning Norwegian and i want to make a global hot key program which sends keys such as

æ
ø
å

我的问题是 keybd_event 函数不允许我发送这些密钥,我似乎仅限于 虚拟键码 是否还有其他我可以使用的功能或发送它们的一些技巧?

My problem is that keybd_event function wont allow me to send those keys, i seem to be restricted to the virtual key codes is there another function that i could use or some trick to sending them?

推荐答案

您必须改用 SendInput.keybd_event 不支持发送此类字符(除非它们已在当前代码页中,例如在挪威计算机上).发送 å 的一些示例代码:

You have to use SendInput instead. keybd_event does not support sending such characters (except if they are already in the current codepage, like on Norwegian computers). A bit of sample code to send an å:

KEYBDINPUT kb={0};
INPUT Input={0};

// down
kb.wScan = 0x00c5;
kb.dwFlags = KEYEVENTF_UNICODE;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));

// up
kb.wScan = 0x00c5;
kb.dwFlags = KEYEVENTF_UNICODE|KEYEVENTF_KEYUP;
Input.type = INPUT_KEYBOARD;
Input.ki = kb;
::SendInput(1,&Input,sizeof(Input));

如果您不知道:在 Windows 上安装其他键盘布局并使用快捷方式在它们之间切换很容易.

In case you didn't know: it is easy to install additional keyboard layouts on Windows and switch between them with a shortcut.

Lykke 直到!

这篇关于如何使用 C++ (keybd_event) 发送 unicode 密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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