I want to move the mouse pointer to a particular location and perform SHIFT + right mouse button click. I am able to move the mouse to a location but not able to simulate mouse click.
Robot r = new Robot();
r.mouseMove(x1,y1);
What should i do to simulate the expected mouse click?
I think you will need just a little extra information for Robot to complete successfully, try
r.keyPress(KeyEvent.VK_SHIFT);
r.mousePress(KeyEvent.BUTTON3_MASK);
r.mouseRelease(KeyEvent.BUTTON3_MASK);
r.keyRelease(KeyEvent.VK_SHIFT);
this should do the trick:
r.mousePress(InputEvent.BUTTON3_MASK);
r.mouseRelease(InputEvent.BUTTON3_MASK);
Important here is not to forget to press and release it, since those are 2 diffrent events.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With