Is there any way of getting this? I'm using the INPUT
class to to simulate key presses, and when wanting to press the key in a variable of type char
, I need to use the following method:
INPUT ip;
ip.type = INPUT_KEYBOARD;
//a bunch of code, and flags...
ip.ki.wVk = toupper(foo);
...where foo is of type char
, and user-defined.
This works fine, until the user inputs a character that's not a regular letter, which results in a completely different key being registered (which is understandable). That's why I'm asking if there's possibly a method that makes me able to get the hexadecimal key code from the variable's value?
I know that I can make a big switch(foo) case '1': //and so on...
to replace the unsupported characters with their corresponding key code, but really, that would mean a lot of unnecessary code.
So, is there any way? Answer is highly appreciated, and if there aren't any, I'll go a head and solve it in a more complicated way. However, since this issue has occured for me several times by now, I figured that it might be good to know for reference.
To turn my comment into an answer...
I think you want VkKeyScanEx(...)
. This will turn a TCHAR
into a virtual keycode and a set of keyboard modifiers that you should be able to use with SendInput(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With