SendInput Function



We had to use the “SendInput Function” to send keystrokes to any active window in our program PikyFolders.

We had troubles using it first. We also referred to many other samples on the Internet. But still it was not clear that after sending every keystroke we must also send the same keystroke with the KEYEVENTF_KEYUP flag to indicate that the key is released.

Basically, to type the character ‘A’, you would need to fill in 2 INPUT structures, one for pressing (without KEYEVENTF_KEYUP flag) and another for releasing (with KEYEVENTF_KEYUP flag).

So for example, if you want to simulate Shift+A, the array of INPUT structures would be as follows.

Press Shift
Press A
Release A
Release Shift

Hope this helps somebody out there.



Leave a Reply

Your email address will not be published. Required fields are marked *