开发者

Simulate right click

开发者 https://www.devze.com 2023-04-10 09:08 出处:网络
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 pr

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 pl开发者_开发知识库ease try to include some code and not just links


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!


Im planning to have a button that u press on a jframe that simulates the right click after x seconds

button.doClick();


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'.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号