Monday, March 8, 2010

Capture Snapshot of PC with Current Resolution . . .(Java Programming)

import java.awt.*;
//get current resolution . . .

Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dm = tk.getScreenSize();
System.out.println(dm);

//Capture snapshot . . .

Robot robot = new Robot();
// Capture the screen shot of the area of the screen defined by the rectangle
BufferedImage bi=robot.createScreenCapture(new Rectangle(dm.width,dm.height));
ImageIO.write(bi, "jpg", new File("D:/imageTest.jpg"));

No comments:

Post a Comment