Created
December 23, 2013 05:19
-
-
Save 64lines/8092042 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.*; | |
import java.awt.image.*; | |
import java.io.*; | |
import javax.imageio.ImageIO; | |
public class Capture { | |
public static void captureScreen(String fileName) throws Exception { | |
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); | |
Rectangle screenRectangle = new Rectangle(screenSize); | |
Robot robot = new Robot(); | |
BufferedImage image = robot.createScreenCapture(screenRectangle); | |
ImageIO.write(image, "png", new File(fileName)); | |
} | |
public static void main(String[] args) { | |
try { | |
JFileChooser fc = new JFileChooser(); | |
int i = 0; | |
while(true){ | |
System.out.println("[ Captura " + (i+1) + "]"); | |
Thread.currentThread().sleep(5 * 1000); | |
String FILENAME = "D:/captura" + i + ".png"; | |
Capture.captureScreen(FILENAME); | |
System.out.println("[ Captura finalizada ]"); | |
i++; | |
} | |
} | |
catch(Exception e){ | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment