The attachment ScreenCapturer.jar contains a nice cup of Java, that captures the entire screen and saves it to a file. Very simple, but effective. Instead of doing the old ”Print Scrn”, Open Paint, Save etc. Just double click the jar file, or invoke it with java -jar ScreenCapture.jar to save a screenshot to c:temp with the name SCREENSHOT_xxxx.png. The source is included in the jar file.
The interesting part is in the captureFullScreen() method, that does the following:
Robot robot = new Robot(); Rectangle area = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()); File target = new File(...truncated path...); saveImageToFile(robot.createScreenCapture(area), target);
It is the java.awt.Robot that fetches the actual screen.
The code is originally from Dick Larsson at ekakan, and I only beautified it a bit. Thanks Dick!