views:

277

answers:

1

Is there a way to convert a sequence of keystrokes represented by the Keys enum (i.e. System.Windows.Forms.Keys) in a Char. For example: Keys.Oem4 and then Keys.A yields the char á. It must exist somewhere in the WinAPI, because Windows does that for me, when I press keys inside a text-box... I just don't know where. Please help! thanks.

EDIT:

What I want is to record the user input keys, and later translate the sequence of keys to characters, without the user having to type everything again, something like a macro.

+2  A: 

The most straight forward way to do this is to first convent the Key value into a Virtual Key code. This is done via KeyInterop.VirtualKeyFromKey. You can then PInvoke into the MapVirtualKey function to convert the key into a char.

JaredPar