snoofkin
snoofkin

Reputation: 8895

Unicode / Russian characters and Win32 api [C++]

I'm trying to catch Russian characters with GetAsyncKeyState() win32 api, but apparently it doesn't seem to work except with English.

Any idea??

CODE:

                for(unsigned char c = 1; c < 255; c++){
                        SHORT rv = GetAsyncKeyState(c);
                    if(rv & 1){ // on press button down
                        string out = "";
                        if(c == 1)
                                out = "[LMOUSE]"; // mouse left
...

Upvotes: 0

Views: 1449

Answers (1)

Hans Passant
Hans Passant

Reputation: 941465

GetAsyncKeyState() lets you inspect virtual keys. A virtual key doesn't become a Russian glyph until the WM_KEYDOWN message is processed by Windows through TranslateMessage(), turning that message into a WM_CHAR based on the current keyboard layout.

Mapping a glyph back to a virtual key is possible with VkKeyScanEx(). This can get rapidly very complicated if the glyph is generated by dead keys. In other words, requiring more than one keystroke. No idea what a Russian keyboard layout looks like, ymmv.

Upvotes: 2

Related Questions