I need to automate mouse clicks with Mathematica. However, a similiar questionsimiliar question was closed on this forum, without any answer.
Consider the following steps:
Dynamic[MousePosition[]]
In this first step I dynamically show the mouse position.
DynamicModule[{col = Green}, EventHandler[ Style["text", FontColor ->
Dynamic[col]], {"MouseClicked" :> (col = col /. {Red -> Green, Green -> Red})}]]
In this second step I create a "clickable" text: when you click it, it changes its color between green and red.
My objective here is twofold:
1) automatically move the cursor position - this has already been answered herehere. So, following the original answer I can write
Needs["JLink`"];
ReinstallJava[];
robotclass = JavaNew["java.awt.Robot"];
robotclass@mouseMove[90, 196];
2) automatically click on the clickable text (and, of course, I want to see its color changing). Here is the code I'm trying to use:
robotclass@mousePress[InputEvent.BUTTON1_MASK];
robotclass@mouseRelease[InputEvent.BUTTON1_MASK];
Although I believe I'm using the correct functions (which belong to the Java Robot Class), I'm getting the following error message:
Java::argx1: Method named mouseRelease defined in class java.awt.Robot was called with an incorrect number or type of arguments. The argument was InputEvent.BUTTON1_MASK.
Can anybody give me a hint to solve this problem?