Ajax (1) Apex Class (12) Apex Trigger (2) Community (2) Home Page (1) HTML (4) Integration (3) JS (7) KB (1) Label (1) Licenses (1) Listing (1) Log (1) OOPs (5) Sharing (1) Static Resource (1) Test Class (3) URI (1) Visualforce (10)

Tuesday 3 June 2014

ScreenRecorder java

import java.awt.image.BufferedImage;
import java.awt.Rectangle;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.Robot;
import java.io.File;
import javax.imageio.ImageIO;
 
class ScreenRecorder {
public static void main(String args[]) {
   try {
       Toolkit tool = Toolkit.getDefaultToolkit();
       Dimension d = tool.getScreenSize();
       Rectangle rect = new Rectangle(d);
       Robot robot = new Robot();
       Thread.sleep(2000);
       File f = new File("screenshot.jpg");
       BufferedImage img = robot.createScreenCapture(rect);
       ImageIO.write(img,"jpeg",f);
       tool.beep();
       } catch(Exception e){
        e.printStackTrace();
      }
    }
}

No comments:

Post a Comment