When I set a system wide keyboard hook using WH_KEYBOARD_LL or WH_JOURNALRECORD, parses it with ToAsciiEx and then types a dead key (ex. ë ê ~ ), this is handled incorrectly in both the key recording and the actual window.
So if I open notepad and start typing when the hook is active, I am unable to even type these dead chars correctly. If I write "ë" it will appear as "¨¨e" instead. So the problem is not only that it is recorded incorrectly but also that ToAsciiEx seems to flush the contents to whatever window is active
According to msdn, this is what happens:
"Two characters were copied to the buffer. This usually happens when a dead-key character (accent or diacritic) stored in the keyboard layout cannot be composed with the specified virtual key to form a single character."
I need help in finding a way to handle these dead keys correctly, so ToAsciiEx would hold this char until it recives the next one it chould be combined with - instead of just inserting an extra dead key and flush it.
bool GetKey(UINT uVirtKey, UINT uScanCode, char *thekey)
KeyLayout = GetKeyboardLayout(0);
UINT uScanCode2 = MapVirtualKeyEx(uVirtKey, 2, KeyLayout);
ascii_result = ToAsciiEx(uVirtKey, uScanCode2, KeyState, (LPWORD)thekey, 0, KeyLayout);