import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class MyScreenCapture {
/**
* @param 자바를 활용한 스크린캡쳐
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Robot robot = new Robot();
//내 모니터 화면의 크기를 가져오는 방법
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
//모니터의 화면을 selectRect에 가로,세로 표현
Rectangle selectRect = new Rectangle((int)screen.getWidth(), (int)screen.getHeight());
for(int i=0; i<10; i++){
BufferedImage buffimg = robot.createScreenCapture(selectRect);
File screenfile = new File("screen"+i+".jpg");
ImageIO.write(buffimg, "jpg", screenfile);
}
} catch (AWTException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}