向应用程序发送按键
有没有一种简单的方法可以让应用程序认为用户已经按下了某个键?
这就是我尝试这样做的原因:
我试图追踪 Wine 应用程序中的回归。该错误似乎仅在用户按下特定键(在本例中为转义键)时才会出现。所以我想给 git bisect 一个脚本来启动应用程序,模拟按转义键,并告诉 git 如果程序崩溃,版本是错误的。
Is there an easy way to make an application think the user has pressed a key?
Here's why I am trying to do this:
I am trying to track down a regression in a Wine application. The bug only seems to show itself when the user presses a specific key (in this case, escape). So I wanted to give git bisect
a script that launches the application, simulates pressing escape, and tells git that that the revision is bad if the program crashes.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用xdotool:http://www.semicomplete.com/projects/xdotool/
Use xdotool: http://www.semicomplete.com/projects/xdotool/
有一些示例代码:http://www. doctort.org/adam/nerd-notes/x11-fake-keypress-event.html
这可能大致就是您所需要的。另请阅读评论(有一个以不同方式选择窗口的示例)。
There is some sample code at: http://www.doctort.org/adam/nerd-notes/x11-fake-keypress-event.html
It might be roughly what you need. Also read the comments (there is a sample for selecting a window in a different way).