Following the advice from this thread: distinguish between keyboard's Real and Virtual key presses
I\'m trying to create a program, that will send keyboard\'s ke
but for now, for testing purposes I'm simulating only keyUP event
Which is okay I guess but that is not going to make Windows do anything. To generate a keystroke, you must first send a KEYDOWN. A "hold-time" doesn't have any useful effect so just put the two SendInput calls in the same method.
You should add error checking, winapi calls don't generate any exceptions. Throw a Win32Exception if the function returns 0. And fix the [DllImport] declaration with SetLastError = true.
You can avoid using that program you found at superuser.com by setting the ki.wVk field instead and omitting the KEYEVENTF_SCANCODE flag. So that you specify virtual keys instead of scan codes. The .NET Keys enumeration type gives you the values you need. Like Keys.A to generate a key press for the A key.