windows 模拟键盘
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6384082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Emulate keyboard
提问by Jacek Koralik
How can I emulate keyboard in application running in background (hidden in tray). I want to press, hold, and relase keys on keyboard programatically. Also, I would like to move mouse around and be able to click.
如何在后台运行的应用程序中模拟键盘(隐藏在托盘中)。我想以编程方式按下、按住和释放键盘上的键。另外,我想移动鼠标并能够点击。
回答by Rajeev
You can use SendInput APIfunction
您可以使用SendInput API函数
回答by ChrisG
You can also try the Windows.Forms.SendKeys API
你也可以试试Windows.Forms.SendKeys API
Here is a How-To: How to: Simulate Mouse and Keyboard Events in Code
这是一个操作方法:如何:在代码中模拟鼠标和键盘事件