Wednesday, 15 August 2012

c# - SendInput hides repeating symbols (seems it doesn't perform KEYUP event) -



c# - SendInput hides repeating symbols (seems it doesn't perform KEYUP event) -

i have app sends character input app. goes fine, if text contain repeating characters (for illustration "app") 1 letter 'p' arrive destination window.

when sending "app" receive "ap". after searching web i've found because missing keyup event. have 1 in code below. what's wrong?

void sendtext(string text) { int len = text.length; int inputssize = len*2; input[] inputs = new input[inputssize]; (int = 0; < 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); }

hm.. i've found decision myself. still don't know why first code didn't work. here's working example. can see - each keyevent sent separate sendinput instead of 1 keyevent package. works needed.

void sendtext(string text) { int len = text.length; int inputssize = len*2; //input[] inputs = new input[inputssize]; input[] inputs = new input[1]; (int = 0; < 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; inputs[0] = inp; sendinput(1, inputs, input.size); inp = new input(); inp.type = 1; //input_keyboard; inp.u.ki.dwflags = keyeventf.keyup | 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 + 1] = inp; inputs[0] = inp; sendinput(1, inputs, input.size); } //sendinput((uint)inputssize, inputs, input.size); }

c# keyup sendinput

No comments:

Post a Comment