SHARE
TWEET

Untitled

a guest Dec 19th, 2012 28 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.AWTException;
  2. import java.awt.Rectangle;
  3. import java.awt.Robot;
  4. import java.awt.Toolkit;
  5. import java.awt.image.BufferedImage;
  6. import javax.imageio.ImageIO;
  7. import java.io.File;
  8. import java.io.IOException;
  9.  
  10. public class ScreenCapture {
  11.         public static void main(String args[]) throws AWTException, IOException
  12.         {
  13.  
  14.                 // capture the whole screen
  15.                 int i=1000;
  16.                 while(true)
  17.                 {
  18.                         i++;
  19.                         Robot robot = new Robot();
  20.                         BufferedImage screencapture = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
  21.  
  22.                         // Save as JPEG
  23.                         // File file = new File("screencapture"+i+".jpg");
  24.                         // ImageIO.write(screencapture, "jpg", file);
  25.  
  26.                         // Save as PNG
  27.                         File file = new File("screencapture"+i+".png");
  28.                         ImageIO.write(screencapture, "png", file);
  29.  
  30.                         try
  31.                         {
  32.                             Thread.sleep(60*4*1000);
  33.                         }
  34.                         catch(Exception e)
  35.                         {
  36.                             e.printStackTrace();
  37.                         }
  38.                 }
  39.         }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top