Scenario
I've written a simple keylogger using the modern RawInput technique registering the desired device for event/data interception.
Then, I'm using basically all these Windows API member definitions:
Problem/Question
I'm using a non-English keyboard with a non-English O.S, then, my problem begins when I try to parse an special key of this keyboard like a ñ/Ñ character which is recognized as an System.Windows.Forms.Keys.OemTilde
key,
or a ç/Ç character which is recognized as an System.Windows.Forms.Keys.OemQuestion
key.
I would like to make my keylogger lenguage-specific aware (or at least, with proper character recognition for my current culture, es-ES), but I'm stuck because lack of knowledges to start retrieving properlly those characters.
Please, note that my intention is to learn how I can do it in an efficient/automated way like the O.S does with my keyboard when I press an Ñ character it types that Ñ, what I mean is that I'm totally aware of a solution that implies to perform a manual parsing of special characters like for example this:
Select Case MyKey
Case Keys.OemTilde
char = "ñ"c
End Select
That is not the behavior that I'm looking for, but I can understand that maybe I need additional "things" to reproduce a good recognition/translation of those chars for each kind of keayborad, but what "things" I need?.
Research
I'm not sure how to proceed, because as I said, I don't have the knowledges to know the answer to this problem (that's why I'm asking), but I imagine that the knowledge of the current keyboard layout will be involved, then, I know that I can retrieve the current keyboard layout with the CultureInfo.CurrentCulture.KeyboardLayoutId
property.
I know that the keyboard layout for culture en-US is 1033, and for culture es-ES is 3082.
Also, note the documentation of the the MakeCode
member of the RAWKEYBOARD
structure, maybe it seems to be a hint for what I pretend to do, I don't know:
MakeCode
Type: USHORT
The scan code from the key depression. The scan code for keyboard overrun is KEYBOARD_OVERRUN_MAKE_CODE.