用于后台(非活动)窗口的 Java 机器人?
在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,那不可能。
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.