在其他窗口中模拟击键
这可能是一个重大的编程罪过,但是通过可执行文件或批处理文件将焦点转移到窗口 X 并按下按键 Y 的最简单、最快的方法是什么?这不会被重用,并且如果需要的话可以对 X 和 Y 进行硬编码。
编辑:在 Windows 机器上
This may be a cardinal programming sin, but what's the easiest and quickest way via executable or batch file to bring focus to Window X and hit keystroke Y? This won't be reused, and X and Y can be hard-coded if necessary.
edit: on a Windows machine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试AutoHotkey或使用win32 API作为MusiGenesis 建议。
You can try AutoHotkey or use win32 API as MusiGenesis suggested.
使用 Win32 API 调用 FindWindowEx 和 SendMessage(如果您希望控制权立即返回到您的应用程序而不等待接收应用程序处理,请使用 SendNotifyMessage)消息)。
当然,假设这是 Windows。
顺便说一句,这并不是什么大罪。除了向其他应用程序发送击键之外,程序还可以做更多邪恶的事情(例如随机删除文件、通过电子邮件将色情内容发送给您的祖母等)。
Use the Win32 API calls FindWindowEx and SendMessage (or SendNotifyMessage if you want control to return to your application immediately without waiting for the receiving application to process the message).
Assuming this is Windows, of course.
This isn't really much of a sin, by the way. There are much more evil things that a program can do than sending keystrokes to other applications (e.g. randomly deleting files, emailing porn to your grandmother etc.).