Robot: createScreenCapture(Rectangle screenRect) : Robot « java.awt « Java by API






Robot: createScreenCapture(Rectangle screenRect)

 

import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

public class Main {
  public static void main(String[] argv) throws Exception {
    Robot robot = new Robot();
    int x = 100;
    int y = 100;
    int width = 200;
    int height = 200;
    Rectangle area = new Rectangle(x, y, width, height);
    BufferedImage bufferedImage = robot.createScreenCapture(area);

    // Capture the whole screen
    area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
    bufferedImage = robot.createScreenCapture(area);

  }
}

   
  








Related examples in the same category

1.Robot: getPixelColor(int x, int y)
2.Robot: keyPress(int keycode)
3.Robot: keyRelease(int keycode)
4.Robot: mouseMove(int x, int y)
5.Robot: mousePress(int buttons)
6.Robot: mouseRelease(int buttons)
7.Robot: mouseWheel(int wheelAmt)