用于后台(非活动)窗口的 Java 机器人?

发布于 2024-10-20 02:54:07 字数 60 浏览 6 评论 0原文

在 Java 中,是否可以使用 Robot 类来模拟非活动 Java 窗口(也称为已最小化到后台)的按键?

In Java, is it possible to use the Robot class to simulate keypresses to a Java window that is inactive (aka, that has been minimized to the background)?

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

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

发布评论

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

评论(1

权谋诡计 2024-10-27 02:54:07

不,那不可能。

Robot 类只是鼠标和键盘(以及其他)的句柄,并且对另一个 Java 应用程序没有特殊权限(就像它对非 Java 应用程序没有任何权限一样)

如果您需要这样做,并且您拥有应用程序的源代码,您可以添加对该应用程序的支持并监听外部应用程序。

如果您没有源代码并且仍然需要这种行为,另一种可能性(取决于您需要做什么)是安装虚拟机(如 VMWare)并在那里运行程序,并将该 VM 最小化。

No, that's not possible.

Robot class is just a handle of the mouse and keyboard ( among others ) and doesn't have special privileges over another Java application ( the same way it doesn't have any privileges over a non java application )

If you need to do this and you have the source code of your application, you can add support for that application and listen external applications.

If you don't have the source code and still need this behavior another possibility ( depending on what you need to do ) is to install a virtual machine ( like VMWare ) and run the program there, and have that VM minimized.

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