Translate key combination to ASCII?

Hi, i have been thinking about how i can translate example (SHIFT + ALT + 2) to @.
I been checking google but i can't find anything, i thought getasynckey would do the trick but then i realized that there are different keyboard layouts by languages.
This actually works, but i have to make sure to know what alt + ctrl and such is.

The code below is what im using, anyone know a better way to do it?


if (this->focused) {
int alltogheter = 0;
if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(VK_MENU)) {
alltogheter = 256 + 256;
alltogheter = alltogheter * 3;
}
if (GetAsyncKeyState(VK_SHIFT) && !GetAsyncKeyState(VK_MENU)) {
alltogheter = alltogheter + 256;
OutputDebugString(L"YEA!");
}
for (int i = 1; i < 255; ++i) {
// The bitwise and selects the function behavior (look at doc)

if (i != 164 && i != 160 && i != 16 && i != 18 && i != 162 && i != 17) {
if (GetAsyncKeyState(i)) {

alltogheter = alltogheter + i;
}
}

// if ctrl + alt = 256 + 256 * 3
// shift = 256


}


DWORD dwThreadID = GetCurrentThreadId();
HKL hCurKeyboard = GetKeyboardLayout(dwThreadID);
SHORT keysdown = VkKeyScanEx('1',hCurKeyboard);
inputtextbox = std::to_string(alltogheter) + " " + std::to_string(keysdown);

}
… wouldn't non-American keyboards be better suited with some sort of Unicode approach? (I don't know, I am just asking).

Probably would but i don't have a clue how i could do it.
Last edited on
I don't either but adjusting ASCII (american standard blah blah) to match non-english keyboards seems like an exercise in frustration.

there is probably a way to ask the OS what keyboard layout it is using. I know windows knows this, but I don't know what function can fetch it.

there is probably a unicode version of the get key function too, but I don't know that either, so I am about useless :)
Don't think there is a GetKey with unicode, if so i haven't found it. :/
You would think there would be. I dunno. None of my big programs communicate with humanoids.

VkKeyScanEx .. is this useful for you?
Topic archived. No new replies allowed.