I have a 2D array containing all letters and their DirectInput key code:
string[,] DXKeyCodes = new string[,]
{
{"a","0x1E"},
{"b","0x30"},
...
};
Then I have a functions that returns from the array the hex key code based on the letter, if I send 'a' it returns '0x1E'.
This key code is then send as a keystroke to an external program by a function that require the key code to be specified as a short, but my array contains strings.
How can I convert this kind of string to a short ?
As an example, this is working but, of course, always sends the same key code :
Send_Key(0x24, 0x0008);
I need something like this to work so I can send any given key code:
Send_Key(keycode, 0x0008);
I have tried the following thing but it does not work either, just crashing my app.
Send_Key(Convert.ToInt16(keycode), 0x0008);
I really don't want to go to something like
if (keycode == "a")
{
Send_Key(0x1E, 0x0008);
}
else if (keycode == "b")
{
Send_Key(0x30, 0x0008);
}
...
I'm sure there is a much better way but I can't find it :(
Thanks for your help.