In a recent post I mentioned a silly Processing sketch, and how Vishal and I made the mouse pointer jump around the screen using a Teensy as a USBHID device. This worked fine, but I mainly did it due to lack of time…

The correct way to make the mouse pointer jump around the screen in Processing is below.

import java.awt.*;
import java.awt.event.*;

Robot robot;

void setup() {
  try {
    robot = new Robot();
  catch (AWTException e) {
    println("Robot class not supported by your system!");

void draw() {
  robot.mouseMove(int(random(1,displayWidth)), int(random(1,displayHeight)));

This code does not work in ProcessingJS, but if you’re running Processing sketches in the IDE or as a standalone application, it works great.

Comments are closed.

« | »

buy the button:

Buy The Button