[英]special characters keybd_event c++
I have a string with special character, like this std::string test = "hello é -";
我有一个带有特殊字符的字符串,例如std::string test = "hello é -";
I want write this string with keybd_event
but special characters wasn't good display.我想用keybd_event
写这个字符串,但特殊字符不能很好地显示。 I do this :我这样做:
std::string result = "Hello é -";
int taille = result.size ();
for (int i = 0 ; i < taille ; i++)
{
keybd_event(VkKeyScan(result.at(i)),0x9e,0 , 0);
keybd_event(VkKeyScan(result.at(i)),0x9e, KEYEVENTF_KEYUP,0);
}
I did some research and found std::wstring
for unicode but even with that it doesn't work, any idea ?我做了一些研究,发现 unicode 的std::wstring
但即使这样它也不起作用,知道吗?
You need to use SendInput()
instead of keybd_event()
, eg:您需要使用SendInput()
而不是keybd_event()
,例如:
std::wstring result = L"Hello é -";
int taille = result.size ();
std::vector<INPUT> inputs(taille);
for (int i = 0; i < taille; ++i)
{
INPUT &input = inputs[i];
input.type = INPUT_KEYBOARD;
input.ki.wVk = 0;
input.ki.wScan = result.at(i);
input.ki.dwFlags = KEYEVENTF_UNICODE;
input.ki.time = 0;
input.ki.dwExtraInfo = GetMessageExtraInfo();
}
SendInput(inputs.size(), &inputs[0], sizeof(INPUT));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.