How to push a key and release it using C#?

c#, keyboard

Solution

I don't think it's possible from .NET directly You could try using keybd_event native call by p/invoking the function as described here: http://pinvoke.net/default.aspx/user32.keybd_event

The MSDN for keybd_event is here: http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx

Hope that helps!

Problem

I am writing a C# program which captures signals from a external device, and sends keystrokes to another application. I am using SendKeys and it works fine. SendKeys does "press" a key by holding and releasing it immediately. I would like to make it push key and release it at will. My question is : "is there a way to send a "push" signal to a key, then a "release" signal after a certain amount of time ?" I am not sure SendKeys is able to do this. Any clue ?

Original source