sending a string as keyboard keystrokes wrongly
as u can see from my following code, KeyBoadText() is a function that accepts a string and then type the string out as if it was typed using the keyboard. but now i am having problem when my typetext = "abc"
instead of typing "abc", it types "123". how can i solve this?
Code:
void CStocksmsDlg::KeyBoardText(CString typetext)
{
int text_len = typetext.GetLength();
for(int i =0; i<text_len; i++)
{
INPUT Input[2];
KEYBDINPUT ki;
ki.dwFlags = KEYEVENTF_EXTENDEDKEY | 0;
ki.time = 0;
ki.wScan = 0;
ki.wVk = typetext.GetAt(i);
Input[0].type = INPUT_KEYBOARD;
Input[0].ki = ki;
ki.dwFlags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP;
ki.dwFlags = KEYEVENTF_KEYUP;
Input[1].type = INPUT_KEYBOARD;
Input[1].ki = ki;
SendInput( 2, Input, sizeof(INPUT) );
}
}