I have a Textbox1 and I want send its text to a program that is working by Virtual Keys.
I have these :
const uint MAPVK_VK_TO_CHAR = 0x02;
public const int WM_SETTEXT = 0x100;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, stringBulder lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int MapVirtualKey(int uCode, uint uMapType);
int txL = textBox1.TextLength;
for (int o = 0; o < (txL-0); o++)
{
int key = MapVirtualKey((int)textBox1.Text[o], MAPVK_VK_TO_CHAR);
SendMessage(hwndTarget, WM_SETTEXT, key, new StringBuilder(key.ToString());
}
I just want to know if any function exists that can convert any char of TextBox to KeyCode ?
I could write a switch : case
but this will be too long. (it contain all unicodes languages too :S)