0

I want to take a screenshot of my screen while in Google Chrome but when my screenshot saves its only my desktop? Im on a mac btw

try  {
    Robot robot = new Robot();
    String format = "jpg";
    String fileName = "FullScreenshot." + format;

    Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    BufferedImage screenFullImage = robot.createScreenCapture(screenRect);
    ImageIO.write(screenFullImage, format, new File(fileName));

    System.out.println("A full screenshot saved!");
} catch (AWTException | IOException ex) {
    System.err.println(ex);
}
  • 1. ensure you are taking a screenshot of the correct monitor. 2. ensure that this code runs when google chrome is on the screen, i.e. add some sort of delay between the code running and the screenshot to let you open chrome – Ben Anderson Sep 26 '22 at 20:09
  • how do i ensure im taking a screenshot of the correct monitor?? – Sawyer Rollins Sep 26 '22 at 20:10
  • well place something unique on each of your monitors and check if it is taking a screenshot of the wrong one – Ben Anderson Sep 26 '22 at 20:16
  • and see [this question](https://stackoverflow.com/q/18301429/14844306) for taking a screenshot of multiple monitors – Ben Anderson Sep 26 '22 at 20:19

0 Answers0