web截屏

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 javax.imageio.ImageIO;

public class ShortCut {
	public static void shortCut() {
		try {
			Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
			BufferedImage bim = new Robot().createScreenCapture(new Rectangle(
					100, 100, dim.width, dim.height));
			ImageIO.write(bim, "jpg", new File("C:\\test.jpg"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static void main(String[] args) {
		shortCut();
	}
}

 

你可能感兴趣的:(Web)