I have app that sends character input into another app. Everything goes fine, but if text contain repeating characters (for example "app") then only one letter 'p' will arrive into destination window.
When sending "app" i receive "ap". After searching the web i've found that this is because missing KEYUP event. But i definitely have one in the code below. What's wrong?
void SendText(string text)
{
int len = text.Length;
int inputsSize = len * 2;
INPUT[] inputs = new INPUT[inputsSize];
for (int i = 0; i < len; i++)
{
INPUT inp = new INPUT();
inp.type = 1; //INPUT_KEYBOARD;
inp.U.ki.dwFlags = KEYEVENTF.UNICODE;
inp.U.ki.time = 0;
inp.U.ki.wVk = 0;
inp.U.ki.wScan = (short)text[i];
inp.U.ki.dwExtraInfo = GetMessageExtraInfo();
inputs[i] = inp;
INPUT inpUp = inp;
inpUp.U.ki.dwFlags = KEYEVENTF.UNICODE | KEYEVENTF.KEYUP;
inputs[i + 1] = inpUp;
}
SendInput((uint)inputsSize, inputs, INPUT.Size);
}