Library that allows for mouse control

Like any other built-in Java library - you need to import it. For example (make sure you know how to quit using Escape!)

import java.awt.Robot;

Robot robot;
int x,y;

void setup() {
 try {
   robot = new Robot();
 } catch (Exception ex) {
  println(ex); 
 }
}

void draw() {
  x++;
  x %= 500;
  y++;
  y %= 500;
  robot.mouseMove(x,y);
}

If you’re using P2D / P3D it’s better to use the JOGL library for this though.

1 Like