I'm trying to type an uppercase letter in an EditBox using the sendInput function to press down Shift then sending a character then KeyUp for the character and for shift.
The Char comes in in the EditBox correctly, however, when I start typing in the EditBox it types everything in CAPS.
It seems that it does not release the Shift Key correctly. Below is my code:
input.Itype := INPUT_KEYBOARD;
input.ki.wVk := VK_LSHIFT;
SendInput(1, input, SizeOf(input));
input.Itype := INPUT_KEYBOARD;
input.ki.wVk := Word('T');
SendInput(1, input, SizeOf(input));
input.Itype := INPUT_KEYBOARD;
input.ki.dwFlags := KEYEVENTF_KEYUP;
input.ki.wVk := Word('T');
SendInput(1, input, SizeOf(input));
input.Itype := INPUT_KEYBOARD;
input.ki.dwFlags := KEYEVENTF_KEYUP;
input.ki.wVk := VK_LSHIFT;
SendInput(1, input, SizeOf(input));
Any help would be greatly appreciated.
I can not reproduce the problem, in my test the "Shift" key doesn't "stick", but as you did not show the complete procedure, I can't investigate/explain why you experience what you do.
A note though:
TInputis a record and records are not automatically zero filled. Thus, fields that you do not assign values to, can have whatever values. Don't know if this might be the reason for the unexpected behaviour.Anyway, it is better to send all keyboard event at the same time, in an array: