Python 将击键发送到非活动应用程序

发布于 2024-08-18 06:48:54 字数 181 浏览 3 评论 0原文

我正在自动执行一些必须在应用程序中执行的常见 GUI 任务,并且我使用 Python 程序和 SendKeys 来完成它。到目前为止,我必须激活要向其发送按键的应用程序(因为 SendKeys 只是将按键发送到活动窗口),但我希望能够将按键发送到后台的应用程序。有没有办法做到这一点,还是我在做一个不可能实现的梦想?

感谢您的帮助。

I'm automating some common GUI tasks I have to do in an application, and I'm using a Python program and SendKeys to do it. So far I've had to activate the application I'm sending keys to (since SendKeys just sends the keystrokes to the active window), but I'd like to be able to send keystrokes to an application in the background. Is there a way to do that, or am I dreaming an impossible dream?

Thanks for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

诗化ㄋ丶相逢 2024-08-25 06:48:54

pywinauto 是另一种仅适用于 MS 的 GUI 自动化工具,这是用 Python 编写的。

pywinauto is another MS-only GUI automation tool, this one written in Python.

原来分手还会想你 2024-08-25 06:48:54
SendKeys is a Python module for Windows that can send one or more keystrokes or keystroke combinations to the active window.

如果您需要在后台执行一些自动化工作,请创建另一个用户/会话并在其中执行此操作。

但是,如果您必须在 Windows 上执行类似的操作,我总是会使用 autoit

它仅包含 M$,非常适合在该操作系统上自动执行任务。

SendKeys is a Python module for Windows that can send one or more keystrokes or keystroke combinations to the active window.

If you need to do some automated work in the background, make another user/session and do it in that.

However if you must do something of this like on windows, I always reach for autoit.

It's M$ only and perfectly suited to automating tasks on that OS.

可爱暴击 2024-08-25 06:48:54

这是 autohotkey.com 论坛中的常见问题。搜索下
“向控件发送命令”。基本上,如果您有控件 ID,则无需使其可见即可对其进行操作。论坛上有更多详细信息。

祝你好运!

This is a frequent question in the autohotkey.com forums. Search under
"sending commands to controls". Basically, if you have the control ID, then it doesn't need to be visible in order to operate on it. There're more details on the forums.

good luck!

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