如何按一个键,使用C#释放呢? [英] How to push a key and release it using C#?
问题描述
我写它可以捕获来自外部设备的信号,并发送键击到另一个应用程序C#程序。我使用的SendKeys,它工作正常。
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.
做的SendKeyspreSS按住并立即释放它的关键。我想使它推键,随意将其释放。
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 ?"
我不知道的SendKeys是能够做到这一点。任何线索?
I am not sure SendKeys is able to do this. Any clue ?
推荐答案
我不认为这是可能的,从.NET直接
的http:这里描述,您可以尝试用p使用keybd_event本地呼叫/调用该函数//的PInvoke。净/ Default.aspx的/ user32.keybd_event
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
在MSDN的keybd_event是在这里:的http:// msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx
The MSDN for keybd_event is here: http://msdn.microsoft.com/en-us/library/ms646304(VS.85).aspx
希望帮助!
这篇关于如何按一个键,使用C#释放呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!