模拟右键单击
我想知道如何让我的Java程序模拟右键单击。所以想象一下你的鼠标不能再点击右键了。如何让Java模拟右键单击?我计划在 JFrame 上按下一个按钮,模拟 x 秒后的右键单击。谢谢,请尝试包含一些代码而不仅仅是链接
I am wondering how to make my Java program simulate a right click. So imagine your mouse cannot right click anymore. How do I make Java simulate the right click? Im planning to have a button that u press on a JFrame that simulates the right click after x seconds. Thanks and please try to include some code and not just links
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
java.awt.Robot
api 正是为此而设计的。里面有很多好东西!具体来说,在本例中, mousePress< /a> 和 鼠标释放。
PS 是的,我意识到它们只是链接。但老实说,学习阅读 API 文档并有效地从中编写代码是每个开发人员都需要的一项技能!
The
java.awt.Robot
api was designed for exactly this. It has lots of goodies in it!Specifically in this case, mousePress and mouseRelease.
P.S. Yes I realize they're just links. But in all honesty, learning to read API docs and make code from them effectively is a skill every developer needs!
视窗?
控制面板|轻松访问 |让鼠标更易用 | 用键盘控制鼠标
顺便说一句, 。鼠标通常不到 10 美元。如果你的时间价值每小时 20 美元,那么你必须在 30 分钟内完成代码,这样比购买新鼠标更便宜。这个项目似乎是一个“虚假经济”。
Windows?
Control Panel | Ease of Access | Make the mouse easier to use | Control the mouse with the keyboard
As an aside. A mouse is usually less that $10. If your time is worth $20 an hour, you'd have to finish the code within 30 minutes to make it cheaper than buying a new mouse. This project seems a 'false economy'.