在java中的预定义坐标处执行左键单击
我想用java在预定义的坐标上执行左键单击。有一个图书馆可以完成这项任务吗?
请注意,我不想实现一个侦听器来查看谁在我的应用程序或任何此类内容中执行了鼠标单击,我只想执行鼠标单击。
谢谢。
I would like to perform a left click at a pre-defined coordinate with java. Is there a library for this task ?
Please notice that I do not want to implement a listener to see who performs a mouse click where in my application or anything of that sort, I simply would like to perform a mouse click.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当
时,不需要外部库java.awt.Robot
可以为您做到这一点。There is no need for an external library, when
java.awt.Robot
can do it for you.如果应在您自己的应用程序的组件上模拟单击,您可以使用 Component.dispatchEvent(AWTEvent) 来传递事件。或者,您可以确定哪个组件位于给定位置并直接传递事件:
If the click should be simulated on a component of your own application, you could use
Component.dispatchEvent(AWTEvent)
to deliver the event. alternatively you could determine which component is at the given location and deliver the event directly: