java 屏幕截图

public static void captureScreen(String fileName) throws Exception {

 
  Toolkit.getDefaultToolkit().getScreenSize();  


    Rectangle screenRectangle = new Rectangle(100, 100);  


    Robot robot = new Robot();  


    BufferedImage image = robot.createScreenCapture(screenRectangle); 


    ImageIO.write(image, "png", new File(fileName)); 


}

你可能感兴趣的:(java)