我正在编写一个 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.
SendKeys 通过立即按住和释放某个键来按下"它.我想让它按键随意释放.
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您可以尝试通过 p/invoking 此处描述的函数来使用 keybd_event 本地调用:http://pinvoke.net/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
keybd_event 的 MSDN 在这里: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# 按下一个键并释放它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!