在其他窗口中模拟击键

发布于 2024-08-04 17:47:22 字数 125 浏览 4 评论 0原文

这可能是一个重大的编程罪过,但是通过可执行文件或批处理文件将焦点转移到窗口 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半山落雨半山空 2024-08-11 17:47:22

您可以尝试AutoHotkey或使用win32 API作为MusiGenesis 建议。

You can try AutoHotkey or use win32 API as MusiGenesis suggested.

乙白 2024-08-11 17:47:22

使用 Win32 API 调用 FindWindowExSendMessage(如果您希望控制权立即返回到您的应用程序而不等待接收应用程序处理,请使用 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.).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文