title: Can I control the mouse cursor from within R?
body: <p>Is it possible, to control the mouse pointer from the R console?</p>
  
  <p>I have something like this in mind:</p>
  
  <pre><code>move_mouse(x_pos=100,y_pos=200)   # move the mouse pointer to position (100,200)
  mouse_left_button_down            # simulate a press of the left button
  move_mouse(x_pos=120,y_pos=250)   # move mouse to select something
  mouse_release_left_button          # release the pressed button
  </code></pre>
  
  <p>In MATLAB, something like this is possible with the following code</p>
  
  <pre><code>import java.awt.Robot;
  mouse = Robot;
  mouse.mouseMove(0, 0);
  mouse.mouseMove(100, 200);
  </code></pre>
  
  <p>I tried a direct conversion of the above into R that looks like this:</p>
  
  <pre><code>install.packages("rJava")          # install package
  library(rJava)                     # load package
  .jinit()                           # this starts the JVM
  jRobot &lt;- .jnew("java/awt/Robot")  # Create object of the Robot class
  </code></pre>
  
  <p>Once I got jRobot in R, I tried to call its metho "MouseMove(100,200)" using the two command below which both resulted in an error.</p>
  
  <pre><code>jRobot$mouseMove(10,10)
  
  Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl,  : 
                java.lang.NoSuchMethodException: No suitable method for the given parameters
  </code></pre>
  
  <p>or </p>
  
  <pre><code>.jcall(jRobot,, "mouseMove",10,10)
  Error in .jcall(jRobot, , "mouseMove", 10, 10) : 
                method mouseMove with signature (DD)V not found
  </code></pre>