What Will I Learn?
Requirements
Resources for Java and this tutorial:
Description
Outline and Overview
Java provides API that allows Screen captured of your PC screen. Java robot class provides the method to enable this and it could be used to make screen shot programs or even video recorder program.
Classes needed
Before we start coding, lets create a new project
this is the code
public class ScreenCapture {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws AWTException, IOException {
// TODO code application logic here
// create a new Robot object
Robot robot = new Robot();
//get screen rectangle
Rectangle screenRectangle = new Rectangle(Toolkit.getDefaultToolkit() .getScreenSize());
// create a new file
File myFileOutput;
int count = 0;
long beforeTime = System.currentTimeMillis();
//capture current screen and save to Screencapture
while (count < 32) {
myFileOutput = new File(count + " screen.png");
BufferedImage Screencapture = robot.createScreenCapture(screenRectangle);
ImageIO.write(Screencapture, "png", myFileOutput);
count++;
}
double time = System.currentTimeMillis() - beforeTime;
System.out.println("Seconds it took for " + count + " screen captures: " + time / 1000);
System.out.println(count + " Images Captured!");
}
}
This is the build output
This is the file output
The Part #1 of this series
https://steemit.com/utopian-io/@enyason/java-tutorial-how-to-make-pc-screenshot-program-with-java-1-single-shot