Hi,

I want to "click" with the mouse using a Robot object like this:

Robot bot = new Robot();
        bot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
        bot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);

This results in:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Invalid combination of button flags

I even delayed the process before it starts clicking to have time to release the mouse but the same exception appears

I finally found it myself... don't know why but it works if I use "BUTTON1_MASK" instead of "BUTTON1_DOWN_MASK".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.