Translate virtual key and scan code to unicode character
I'm trying to translate vkCode and scanCode from KBDLLHOOKSTRUCT to unicode characters, based on current keyboard:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
unsigned char btKeys[256] = {0};
if(!GetKeyboardState(btKeys)) {
printf("Error: %ld\n", GetLastError());
}
HKL keyboardLayout = GetKeyboardLayout(0);
wchar_t szBuffer[2] = {0};
if (ToUnicodeEx(vkCode, scanCode, btKeys, szBuffer, 2, 0, keyboardLayout)) {
if (iswcntrl(szBuffer[0])) {
sendControl(szBuffer[0]);
return;
}
sendUnicode(szBuffer[0]);
};
| |
However that only returns alphanumeric characters, as if no modifiers (shift, control, alt) were pressed. How can I fix that?
Topic archived. No new replies allowed.