I am trying to get the Robot class to right click on a image on the screen so that I can save it. The problem is though that I cannot seem to get the Robot to successfully simulate a right click. Here is some sample code of what I am doing.
It seems that BUTTON2_DOWN_MASK is the mask for the scroll wheel. Whenever I execute this code it first just regularly clicks at the location but then the scroll wheel super fast move circle pops up and tells me I can now scroll at light speed, but I wanted a right click..
CODE:
// This is the function I use to simulate a full click at location x,y on the screen
// Rob is my Robot
public void click(int x, int y, int mask)
{
rob.mouseMove(x, y);
sleepy(1000);
rob.mousePress(mask);
rob.mouseRelease(mask);
}
// This is the few lines of code that call this function
// sleepy just calls the Thread.sleep function.
sleepy(1000); // Wait one second
click(705, 390, InputEvent.BUTTON1_DOWN_MASK);
sleepy(1000);
click(705, 390, InputEvent.BUTTON2_DOWN_MASK);
sleepy(1000);