简体   繁体   English

如何使用c ++发送unicode密钥(keybd_event)

[英]How to send unicode keys with c++ (keybd_event)

My friend is learning Norwegian and i want to make a global hot key program which sends keys such as 我的朋友正在学习挪威语,我想创建一个全局热门密钥程序,它可以发送密钥等

æ
ø
å

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? 我的问题是keybd_event函数不允许我发送这些密钥,我似乎只限于虚拟密钥代码是否有我可以使用的其他功能或发送它们的一些技巧?

You have to use SendInput instead. 您必须使用SendInput。 keybd_event does not support sending such characters (except if they are already in the current codepage, like on Norwegian computers). keybd_event不支持发送此类字符(除非它们已经在当前代码页中,就像在挪威计算机上一样)。 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));

In case you didn't know: it is easy to install additional keyboard layouts on Windows and switch between them with a shortcut. 如果您不知道:在Windows上安装其他键盘布局很容易,并使用快捷方式在它们之间切换。

Lykke til! Lykke直到!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM