I have got the following keyboard layouts in system:
I created the following QWERTZ / AZERTY detection function:
bool bIsAzertyKeyboard = false;
bool bIsQwertzKeyboard = false;
bool bIsQwertyKeyboard = false;
void DetectKeyboardType() {
bIsAzertyKeyboard = false;
bIsQwertzKeyboard = false;
bIsQwertyKeyboard = true;
switch (PRIMARYLANGID(LOWORD(GetKeyboardLayout(0))))
{
case LANG_FRENCH:
bIsQwertyKeyboard = false;
bIsAzertyKeyboard = true;
break;
case LANG_GERMAN:
bIsQwertyKeyboard = false;
bIsQwertzKeyboard = true;
break;
}
}
Unfortunately, I'm getting troubles detecting for the correct keyboard language, when it's a keyboard installed under a different language.
For example: bIsQwertzKeyboard
is true
only when the selected keyboard language is DEU
. When I select ENG DE
, the Y and Z are getting inverted, but bIsQwertzKeyboard
is false
.
How can I detect for the QWERTZ keyboard in all cases?
Looks like I solved it!
Replacing:
switch (PRIMARYLANGID(LOWORD(GetKeyboardLayout(0))))
to:
switch (PRIMARYLANGID(HIWORD(GetKeyboardLayout(0))))
does the trick, I was attempting to use the "SUBLANGID" instead. but that's something else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.