File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes capture system screen to a gif file![immdtly.] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "capture system screen to a gif file![immdtly.]" Watch "capture system screen to a gif file![immdtly.]" New topic
Author

capture system screen to a gif file![immdtly.]

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hi, I want to capture the system screen & save it as a gif file,is it possible in java.I want to capture it for every user-defined seconds.This should be done without any key press or user-action.This capture should be done even without the notice of the current user.
Happy middling with java.
Netharam:confused.
Rob Ross
Bartender

Joined: Jan 07, 2002
Posts: 2205
Are you building some kind of spy-tool Nethram?
Also, there really is no need to include words like "immediately" in your header. First, people are NOT going to answer you any faster. People come and go, most browse, and some people actively look for questions to answer. I answer questions as I find them, regardless of whether someone has written "URGENT" or RESPOND NOW or anything like that. In fact, I find it a little rude when people do that, but that's just my personal opinion.
To answer your questions though, I think java.awt.Robot.createScreenCapture() will work for you. You can create a background thread that snapshots the screen every N seconds as you like, and saves it to an image buffer. Other threads can then read from it, or save it , or send it somewhere, or do whatever you can do with an image.
Good luck.


Rob
SCJP 1.4
Matt Payne
Greenhorn

Joined: Jun 29, 2002
Posts: 1
/*
* ScreenCaptureDemo.java - demos screen captures with the Robot class. Has small bug, but works.
*
* Created on June 29, 2002, 6:11 PM
*/
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
import java.awt.print.*;
import com.sun.image.codec.jpeg.*;
/**
*
* @author payne
*/
public class ScreenCaptureDemo {

/** Creates a new instance of ScreenCaptureDemo */
public ScreenCaptureDemo() {
}

public static void main(String[] arg) {
JFrame jf = new JFrame("A frame");
Container c = jf.getContentPane();
c.setLayout(new FlowLayout());
c.add(new JButton("Robot screen capture demo based on"));
c.add(new JButton("http://www.java-conf.gr.jp/archives/servlet-ml/msg01910.html"));
c.add(new JButton("which was found with searches on Google.com"));
jf.pack();
jf.show();

Dimension d = jf.getSize();
int hFudgeFactor=30; // getSize() doesn't get the whole size
Rectangle rect1 = new Rectangle(d.width, d.height+hFudgeFactor);
Graphics2D g = null;
Image im = null;
BufferedImage img = null;

try {
Robot r1 = new Robot();
im = r1.createScreenCapture(rect1);
// make an image (img) to save im into
img = new BufferedImage(d.width,d.height+hFudgeFactor, BufferedImage.TYPE_INT_RGB);
g = img.createGraphics(); // We'll speak to img via a graphics object
g.drawImage(im, null, null); // draw the im into g

// Encode the off screen image into a GIF and save it to a file
FileOutputStream out = new FileOutputStream("/tmp/x.jpg");
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(img);
out.flush();

} catch (Exception e) {
e.printStackTrace();
}


}

}


Share & Enjoy! -Matt<br />Payne@MattPayne.org
 
 
subject: capture system screen to a gif file![immdtly.]