Help with error in Robot class and createScreenCapture() method

PImage screenshot;
import java.awt.Robot;

void setup() {
size(400,300);
}

void draw() {
try {
Robot robot = new Robot();
screenshot = new PImage(robot.createScreenCapture(new Rectangle(0,0,screen.width,screen.height)));

 } catch (AWTException e) {
 }

image(screenshot, 0, 0, width, height);
screenshot(0,0,width, height);
}

this is the error:

The method createScreenCapture(java.awt.Rectangle) in the type Robot is not applicable for the arguments (Rectangle)

Hello,

Please format your code:
FAQ - Processing Foundation

Here is a working example:
Screen capture in Processing – Magic & Love Interactive

Subject is much too long and could be shortened from:

Why does my program return the error, The method createScreenCapture(java.awt.Rectangle) in the type Robot is not applicable for the arguments (Rectangle)?

To:

Help with error in Robot class and createScreenCapture() method

Or similar…

And then more details in the body of topic.

:)

Hello @MoonAlien822

Not to get too into the weeds on this, but… :upside_down_face:

one of the important things about topic titles is that they include “searchable” keywords so that others who may have a similar question at a later date can find previous topics in the database of topics.

It saves time for people seeking answers as well as those providing answers.

Your topic line is now super generic and not really findable for others. GLV’s suggested topic line uses relevant keywords and is therefore findable.
Just something to keep in mind going forward…
:nerd_face:

2 Likes

i had this at first but there was another answer saying that it was too long.

Yes. Your original title WAS too long. I was directing you to GLVs suggested shorter title that includes the relevant keywords here:

EDIT: Ok, I see it is now changed. :slight_smile:

2 Likes

forum.Processing.org/two/discussion/8025/take-a-screen-shot-of-the-screen#Item_8

1 Like