如何在C#中模拟按键?
Google 提供了 this 但它似乎只适用于 WindowsForms 类。我对 C# 完全陌生。我想要制作的是一个监视事件的程序,然后(例如)就像按下了“H”键一样。我真的不想担心活动窗口是什么或任何东西,或者向应用程序发送击键,我只是希望程序表现得就像我实际按下了键盘上的“H”按钮一样。 SendKeys 类似乎在一般类中不起作用。我的处理方式完全错误吗?
Google gives this but it seems to only work for a WindowsForms class. I'm completely new to C#. What I'm trying to make is a program that monitors for an event, and then (for example), acts as if the 'H' key has been pressed. I don't really want to worry about what the active window is or anything, or sending a keystroke to an application, I just want the program to act as if I have physically pressed the 'H' button on my keyboard. The SendKeys class doesn't seem to work in a general class. Am I going about this completely the wrong way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自如何:在代码中模拟鼠标和键盘事件< /strong>:
From How to: Simulate Mouse and Keyboard Events in Code: