Converting char to keyboard-mapped code

  • Thread starter Thread starter Santy
  • Start date Start date
S

Santy

Hi! Suppose I detected, using DInput, the 1 key is pressed. I wanna get the
shift+1 symbol on the current culture-keyboard....

For example.... In my spanish keyboard, shift+1 yields a "!". This is not
valid for ALL the keyboards in the world... so How can I get the [shift]+1
keyboard-mapped character?

thx in advance.
 
Well, there is no built-in way to do this, is thats what you are asking. It
is some fancy usage via pinvoke of the ToUnicode() API (the MS Keyboard
Layout Creator has to do this when you load from an existing layout).
 
Note, however, that doing this will ruin the keystroke buffer for things
like dead keys -- so it will actually hurt the ability to input data if you
go this route (a painful lesson learned while MSKLC was being developed!).

Realistically, you would have to

1) At the start of the app, obtain and store the information on every single
possible keystroke and dead key in the keyboard layout;

2) Listen for WM_INPUTLANGCHANGE messages

3) Any time it changes, re-run step #1 with the new layout

4) Any time there is a keystroke, get the information on what you want.

By no means, a trivial exercise. But the above plan has the advantage of
working properly....

--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.



Michael (michka) Kaplan said:
Well, there is no built-in way to do this, is thats what you are asking. It
is some fancy usage via pinvoke of the ToUnicode() API (the MS Keyboard
Layout Creator has to do this when you load from an existing layout).


--
MichKa [MS]

This posting is provided "AS IS" with
no warranties, and confers no rights.


Santy said:
Hi! Suppose I detected, using DInput, the 1 key is pressed. I wanna get the
shift+1 symbol on the current culture-keyboard....

For example.... In my spanish keyboard, shift+1 yields a "!". This is not
valid for ALL the keyboards in the world... so How can I get the [shift]+1
keyboard-mapped character?

thx in advance.
 
Back
Top