I cant find out why when i call Enter(0x1c) in inp[2] and inp[3] the KEYEVENTF_KEYUP flag not working so the key stays pressed forever.
I recreated a simplified code without the string part and there it was working well.
So maybe its coming from there.
Code:SendString(_T("dellserv"), 0x1c); static void SendString(LPCTSTR str, int ScanCode) { INPUT inp[4]; memset(inp,0,sizeof(INPUT)); inp[0].type = INPUT_KEYBOARD; inp[0].ki.dwFlags = KEYEVENTF_UNICODE; inp[1] = inp[0]; inp[1].ki.dwFlags |= KEYEVENTF_KEYUP; inp[2] = inp[0]; inp[2].ki.dwFlags = KEYEVENTF_SCANCODE; inp[3] = inp[0]; inp[3].ki.dwFlags |= KEYEVENTF_KEYUP; for (LPCTSTR p=str; *p; p++) { inp[0].ki.wScan = inp[1].ki.wScan = *p; SendInput(4, &inp[0], sizeof(INPUT)); SendInput(4, &inp[1], sizeof(INPUT)); } if(ScanCode != 0) { inp[2].ki.wScan = inp[3].ki.wScan = ScanCode; SendInput(4, &inp[2], sizeof(INPUT)); SendInput(4, &inp[3], sizeof(INPUT)); } }



LinkBack URL
About LinkBacks




