Allen_L

screencapture_test

Jul 2nd, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  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 java.io.File;
  7. import java.io.IOException;
  8. //import java.util.Scanner;
  9. import javax.imageio.ImageIO;
  10.  
  11. /**
  12.  *
  13.  * @author eoin
  14.  */
  15. // I changed the class name to Capture
  16. public class Capture {
  17.     private static int a = 1;
  18.  
  19.     /**
  20.      * @param args
  21.      *            the command line arguments
  22.      * @throws java.awt.AWTException
  23.      * @throws java.io.IOException
  24.      */
  25.     public static void main(String[] args) throws AWTException, IOException,
  26.             InterruptedException {
  27.  
  28.         System.out.println("  {__   {__  {__   {__    {___ {__ {__ ");
  29.         System.out.println("{_  {__ {__  {__ {__  {__  {__  {_  {__");
  30.         System.out.println("{_  {__ {__  {__{__   {__  {__  {_  {__");
  31.         System.out.println(" {__{__ {__  {__{__   {__  {__  {_  {__");
  32.         System.out.println("    {__   {__{__  {__ {___{___  {_  {__");
  33.         System.out.println("    {___  ");
  34.         System.out.println("GNU general public");
  35.  
  36.         // System.out.println("Start screen recording?: Y/N");
  37.         // Scanner scan = new Scanner(System.in);
  38.         // int framerate = scan.nextInt();
  39.  
  40.         // framerate = a;
  41.  
  42.         // TODO code application logic here
  43.  
  44.         while (a < 15) {
  45.             Thread.sleep(1000L);
  46.  
  47.             // do something
  48.             // pause to avoid churning
  49.  
  50.             /*
  51.              * Hammer the JVM with junk
  52.              */
  53.  
  54.             a++;
  55.             System.out.println("FRAME" + a);
  56.             /* File location is C:\Users\computerName\screenshot.png */
  57.            
  58.             // I made changes here
  59.             File saveImage = new File(System.getProperty("user.home")
  60.                     + "/Desktop" + "\\screencast" + a + ".png");
  61.            
  62.            
  63.             /* Define how much area you want to capture */
  64.             Rectangle rectangle = new Rectangle(Toolkit.getDefaultToolkit()
  65.                     .getScreenSize());
  66.             /* Capture image */
  67.             BufferedImage imageCapture = new Robot()
  68.                     .createScreenCapture(rectangle);
  69.             /* Write BufferedImage to file */
  70.             ImageIO.write(imageCapture, "png", saveImage);
  71.  
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment