Although this is not natively possible as far as i know, you can simply calculate this position, as it is relative to the position of the sketch window. Just use instead of mouseMove(x, y); this : mouseMove(sketchX + x, sketchY + y); .This moves the mouse to the position of the sketches left upper corner and then to the position inside the sketch (actually it only moves it to the position inside the sketch, but the thinking behind sketchX moving it to start at the top left of the sketch and then x moves it further probably explains it a bit better).
Here is a method to get the location of the window by @quark
PVector getWindowLocation(String renderer) {
PVector l = new PVector();
if (renderer == P2D || renderer == P3D) {
com.jogamp.nativewindow.util.Point p = new com.jogamp.nativewindow.util.Point();
((com.jogamp.newt.opengl.GLWindow)surface.getNative()).getLocationOnScreen(p);
l.x = p.getX();
l.y = p.getY();
} else if (renderer == JAVA2D) {
java.awt.Frame f = (java.awt.Frame) ((processing.awt.PSurfaceAWT.SmoothCanvas) surface.getNative()).getFrame();
l.x = f.getX();
l.y = f.getY();
}
return l;
}
And here’s the question to it :
So the code will look similar to this :
PVector windowPos = getWindowLocation("P2D");
Robot.mouseMove(windowPos.x + x, windowPos.y + y);