Robot Class (Screen Capture)

Hello friends,
i have a problem and i don't know if it's a bug or something wrong with my code i just developed this code below to create a screencapture application and i do get the screen capture in the jpeg format but the problem is that i don't see the mouse pointer in the screenshot that i get why don't i see the mouse pointer when i can see everthing else
import java.awt.*;
import java.awt.Image.*;
import javax.imageio.*;
import java.io.*;
public class test{
public static void main(String args[]){
try{
Robot tt=new Robot();
Rectangle screen=new Rectangle(1024,768);
File f1 = new File("/home/hari/java/test.jpg");
javax.imageio.ImageIO.write(tt.createScreenCapture(screen),"jpg",f1);
}catch(Exception e){System.out.println(e);}
I would like u guys to go through this code and check my claims
one more thing u need jdk1.4 for this as iam using java advanced imaging api
Thanks in advance
regards
hari

Hey,
Why did you ask me that question this is a fully functional code tested on linux and windows and works, Except for i don't see the mouse pointer at all as i already mentioned you should have jdk1.4 for this
Please let me know as my running out of patience because of this problem
regards
hari

Similar Messages

  • Robot class, image capture

    Hi,
    Is there a way, either using the robot class or not, to capture just a small portion of the desktop image?
    Many thanks, Ron

    Real time is not posible in this case
    to take on screen capture it takes about 250 milli secs
    to convert it in to a buffer of bytes it will take equal time.
    what I recomend to you is to create a mediastream and broadcase it to do this you will need to learn about Java Media Framework
    By the way I tryied this and it is not real time I only manage to take 4 screen captures per sec. In the most improved version of my code

  • FLV Screen Capture

    Hi everyone,
    I'm trying to use the Robot class to capture images from the screen and encode them to an FLV stream on the fly.
    Anybody have any pointers or a general direction to take to start this?
    I already have the Robot class capturing images from the region of the screen that I want, I am at the point where I have no idea how to encode them to an FLV stream.
    Thank You!

    Was the link given to you more than a month ago any use? I have to ask because it looks like you abandoned the thread.
    [http://forums.sun.com/thread.jspa?threadID=5334103]
    db

  • How to capture a screen by using robot class

    how to capture a screen by using robot class

    open the apidocs for the Robot class
    read the methods - you won't get far when one of the methods will stand out
    if you can't get it working, copy the method name and paste it into the 'search forums' box,
    where you'll find plenty of sample code

  • Robot screen capture problem on Mac os 10

    Dear all,
    I perform a screen capture with jframe size.The background capture is ok but i have a line border around the rectangle determined by the capture and a shadow in capture background..
    How to remove the line border of capture, and suppress the shadow on mac ....
    Thanks in advance for all helps..
    package nomadsland.splashWindow;
    import java.awt.AWTException;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.awt.image.ConvolveOp;
    import java.awt.image.Kernel;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JWindow;
    import javax.swing.Timer;
    public class ShadowedWindow extends JWindow {
        private BufferedImage splash = null;
        public ShadowedWindow(BufferedImage image) {
            createShadowPicture(image);
        public void paint(Graphics g) {
            if (splash != null) {
                g.drawImage(splash, 0, 0, null);
        private void createShadowPicture(BufferedImage image) {
            int width = image.getWidth();
            int height = image.getHeight();
            int extra = 14;
            setSize(new Dimension(width + extra, height + extra));
            setLocationRelativeTo(null);
            Rectangle windowRect = getBounds();
            splash = new BufferedImage(width + extra, height + extra, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D) splash.getGraphics();
            try {
                Robot robot = new Robot(getGraphicsConfiguration().getDevice());
                BufferedImage capture = robot.createScreenCapture(new Rectangle(windowRect.x, windowRect.y, windowRect.width + extra, windowRect.height + extra));
                g2.drawImage(capture, null, 0, 0);
            } catch (AWTException e) { }
            BufferedImage shadow = new BufferedImage(width + extra, height + extra, BufferedImage.TYPE_INT_ARGB);
            Graphics g = shadow.getGraphics();
            g.setColor(new Color(0.0f, 0.0f, 0.0f, 0.3f));
            g.fillRoundRect(6, 6, width, height, 12, 12);
            g2.drawImage(shadow, getBlurOp(7), 0, 0);
            g2.drawImage(image, 0, 0, this);
        private ConvolveOp getBlurOp(int size) {
            float[] data = new float[size * size];
            float value = 1 / (float) (size * size);
            for (int i = 0; i < data.length; i++) {
                data[i] = value;
            return new ConvolveOp(new Kernel(size, size, data));
        public static void main(String[] args) {
            try {
                 BufferedImage image = ImageIO.read(ShadowedWindow.class.getResourceAsStream("loginPanelGeneric.png"));
                ShadowedWindow window = new ShadowedWindow(image);
                window.setVisible(true);
                Timer timer = new Timer(5000, new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        System.exit(0);
                timer.start();
            } catch (IOException e) {
                e.printStackTrace();
    }Thanks you in advance for any help...

    Dear all,
    I perform a screen capture with jframe size.The background capture is ok but i have a line border around the rectangle determined by the capture and a shadow in capture background..
    How to remove the line border of capture, and suppress the shadow on mac ....
    Thanks in advance for all helps..
    package nomadsland.splashWindow;
    import java.awt.AWTException;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Rectangle;
    import java.awt.Robot;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.image.BufferedImage;
    import java.awt.image.ConvolveOp;
    import java.awt.image.Kernel;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JWindow;
    import javax.swing.Timer;
    public class ShadowedWindow extends JWindow {
        private BufferedImage splash = null;
        public ShadowedWindow(BufferedImage image) {
            createShadowPicture(image);
        public void paint(Graphics g) {
            if (splash != null) {
                g.drawImage(splash, 0, 0, null);
        private void createShadowPicture(BufferedImage image) {
            int width = image.getWidth();
            int height = image.getHeight();
            int extra = 14;
            setSize(new Dimension(width + extra, height + extra));
            setLocationRelativeTo(null);
            Rectangle windowRect = getBounds();
            splash = new BufferedImage(width + extra, height + extra, BufferedImage.TYPE_INT_ARGB);
            Graphics2D g2 = (Graphics2D) splash.getGraphics();
            try {
                Robot robot = new Robot(getGraphicsConfiguration().getDevice());
                BufferedImage capture = robot.createScreenCapture(new Rectangle(windowRect.x, windowRect.y, windowRect.width + extra, windowRect.height + extra));
                g2.drawImage(capture, null, 0, 0);
            } catch (AWTException e) { }
            BufferedImage shadow = new BufferedImage(width + extra, height + extra, BufferedImage.TYPE_INT_ARGB);
            Graphics g = shadow.getGraphics();
            g.setColor(new Color(0.0f, 0.0f, 0.0f, 0.3f));
            g.fillRoundRect(6, 6, width, height, 12, 12);
            g2.drawImage(shadow, getBlurOp(7), 0, 0);
            g2.drawImage(image, 0, 0, this);
        private ConvolveOp getBlurOp(int size) {
            float[] data = new float[size * size];
            float value = 1 / (float) (size * size);
            for (int i = 0; i < data.length; i++) {
                data[i] = value;
            return new ConvolveOp(new Kernel(size, size, data));
        public static void main(String[] args) {
            try {
                 BufferedImage image = ImageIO.read(ShadowedWindow.class.getResourceAsStream("loginPanelGeneric.png"));
                ShadowedWindow window = new ShadowedWindow(image);
                window.setVisible(true);
                Timer timer = new Timer(5000, new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        System.exit(0);
                timer.start();
            } catch (IOException e) {
                e.printStackTrace();
    }Thanks you in advance for any help...

  • Query regarding screen capture in webdynpro

    Hi
    i needed to use the java.awt.Robot class to perform a screen capture. This is basically used to capture signature which is done on a applet. But hwile i am using it gives me java.awt.headless exception which basically means that i cannot use display devices or certain other features. is there any way get past this.
    Is there any way i can do a screen capture using webdynpro.
    I have few more doubts regarding a application that i need to make. If i am not able to get a solution for this problem i would explain the scenario and probably someone could help me with solution for the same
    thanks
    regards
    Srikumar V

    The problem is that the iframe control is not really supported and should not be used anymore i think.
    But anyways: Since there is actually no out of the box solution, the steps you would hav to go are as follows:
    1. Get Access to the image data (client side)
    I suppose the paint method of one of the AWT/Swing components is overwritten to draw the signature with a pointig device (eg mouse/touch screen)
    in the method public void paint(Graphics g) you have access to the component's Graphics object.
    When the user presses a button in that applet you need to get the latest graphics object of the component and get the bitmap data out of it.
    This is basically the same as using the java robot screenshot, just more elegant.
    But it is important of course, that the navigation to the new view is somehow triggered by the applet so that it can send the request to the servlet before the applet is destroyed.
    2. Send the data to the Server
    I think the best would be to write a servlet to accept the bitmap data from the applet and store it to a database. When the File is uploaded you have to navigate to the next view (using portal navigation or javascript to reload the parent frame)
    Then you need to query that database from Webdynpro to get the file.
    3. Now you would have to use a library like iText to create a PDF file with your image in it.
    This is all not really easy and I can only describe some rough ideas. I cannot think of an easier way to do it right now since client side coding is not supported by webdynpro.

  • Help! Screen Capture with JDK 1.1.8

    Hi,
    I have JDK 1.1.8 application. I am looking for a solution that captures screens and saves the image to one of image formats (any one of jpeg or gif or png is fine). In the news group, I found articles of how doing this using later versions of JDK (like using 1.2 or later). I appreciate for any pointers.
    Thanks
    Puri

    There is nothing in JDK 1.1.x or lower that provides this functionality. I'm not sure about 1.2 either. The java.awt.Robot class which has this functionality says since 1.3 in the API docs. If you need this in 1.1 or lower, you need to use JNI if there's a native way to do it, or exec some other application that does this, if there is one installed.
    Or, time to upgrade.

  • Screen capture and streaming it

    how can i capture the screen and send it on a network.the transfer has to be in real time.will using robot class and then sending the buffered image be in real time
    plz help

    if you are using unix, you can the "xwd" command...
    you can also search the forum for screen captures with the robot class, i'm pretty sure there are plenty of topic on that

  • Screen capture with mouse pointer

    I know this is old question. but i couldnt find the solution. i have code for screen capture using robot class. i think you know the code i am talking about. it works well. but the problem is i want to capture the mouse pointer also. i searched in google, and i didnt get it. i think i didnt search well or i dont know how to search to get the answer. so if any one HELP me means, it will be usefull for me:-)

    You can query the mouse's location using MouseInfo.

  • Problem figuring out annotation using Robot class

    HI
    I have made a desktop sharing tool using the robot class in java. On the server end it captures screen and on the client end i have used a jlabel to diplay it....
    Now i want to extend it to allow users to draw on screen while that is being transmitted to the client end.
    The major problem for me is i dont know how do i get the frame being transmitted as the window i create to diplay the contents being capture would come to the top and hence its contents will be captured by the robot class......
    How can i solve this????
    Thanx in advance...

    I can suggest to you a solution to "draw" on the screen, but you won't be able to see what you're drawing as you draw it.
    You'll need a seperate thread to poll the position of the mouse every 20 or so milliseconds. You can use
    java.awt.MouseInfo.getPointerInfo().getlocation();to get the location of the mouse.
    You then implement your drawing algorithms to draw on a BufferedImage of TYPE_4BYTE_ABGR or any of the other types that support transparency. Of course, the image needs to be the size of the screen. Then on every single image you stream, you draw your ABGR image ontop of the one you are about the stream. Voila.
    As I said though, you can't actually see what you're drawing. In order to see what you are drawing you need to display it in a window that scales down the images and is unobtrusive. Of course, this window in turn will be caught by the screen capture, so the clients will be able to "see" your helper window.
    On the other hand, if all you are doing is streaming images of a *single java window* (not the whole desktop) and all you need to do is draw on that single java window, then I can reccomend to you a better solution that utilizes the GlassPane for drawing. By using the the glass pane, the drawings will appear directly on the window, and you don't need a helper window to see your drawings.

  • How do I connect two video cameras to my computer have them both show up on the desktop at the same time so I can see and capture both images using a screen capture program?

    Hello, 
    I am a teacher and want to make some videos to post online for my class.  I would like to have it set up so that I have a powerpoint presentation going, a video camera pointing at a piece of paper I can write on and another video camera pointing at me.  How do I do this?  I have seen several solutions but they seem to be for switching between videos whereas I want both video images to be on at the same time.
    Also, is there a screen capture program you would recommend?

    Go to System Preferences - Sharing and change the computer name there. You can also, optionally, change the name of your hard drive to further clarify the origin of your backups. Click once on the "Macintosh HD" on your desktop, then click its name to allow you to edit it.
    Matt

  • How can I keep my screen captures sharp when exporting to PDF?

    I've tried using a screen capture tool that allows me to snag in the exact size, plus I changed downsampling to none in the export settings, but the screen captures still look blurry in the PDF. What else can I do to keep them looking sharp?
    My client insists on using InDesign to lay out this presentation and wants a sharp looking PDF to send to clients.

    Ok, there's the problem. You turned off effective compression of the photos.
    I don't know how, or whether, you can have different compression for different image classes in InDesign. That's really a question for an InDesign forum.
    Good luck!

  • Trying to increase the sound of recorded screen captures

    Hi. I'm making screen capture movies with Snapz PRo 2 and they are being saved as QT movies on my desktop. When I open them in QT and try to increase the sound volume, the setting don't stick if I try to raise the volume over 0db. I read somewhere that QT won't let you save volume over 0db, is that true?
    If so, does anyone know how I can increase the gain on the movies without having to load them into Final Cut or iMovie? Is there some program that will let me just edit the sound of a QT movie?
    Thanks in advance.
    Antonio

    Hey, thanks for the tips. But... I don't think I'm making myself clear here.
    I don't want to spend ANY time in post with these tutorial screencasts that I'm making. If I did, I'd just whip out my Sennheiser and my mixer and take the whole shebang into FCP and cut it and sweeten audio there.
    What I'm doing is using Snapz to capture screen actions that I'm recording as tutorials for my students. I'm using either a Blue Snowball USB mic or my Logitech 250 USB headset with mic to record my voice as I demo apps on the Mac. Snapz is using the Apple animation codec to make the movies. But, what Snapz is not doing and cannot do is help me boost the audio a bit. If it did, then I'd have a finished movie right there. As it is, I have to wait a long time for Snapz to finalize the flick. What I don't want to do is load the film up in FCP (takes time) and then export it (also takes time) and be done. I want to package these things up fast. All I need to do is boost the audio a little and everything would be great. If Quicktime Pro allowed me to do that, that would be great because it would not have to re-encode the movie again.
    Maybe there is no way to do what I'm asking without doing it in FCP. If that's the case then that's what I'll do.
    THe whole point of this is that I want to keep it as simple and as past as possible because I am not making any money doing this (but I am teaching for money). I offer it to my students as a value added addition to their classes.
    Thanks,
    Antonio

  • Robot class and positioning the cursor

    I have an application where I have a number of panels on the screen and using an editable field wish to enter coordinates to position the Cursor to on another panel.
    ie, using grid coordinates on a map. Using the robot class I am able to position the cursor on the other panel but as soon as I move the mouse the cursor jumps back to the original position on the screen where the first panel with the editable field was. It is like only a picture of the cursor was drawn at the new coordinates and the real cursor is still at the old podition. It is important to this application that if the cursor is moved it stays where it has been moved to and actually is there and not just appearing to be there. I am using jdk 1.3 on Intel Solaris 2.8. Any help on this issue would be helpful and appreciated

    Maybe you can use the mouse move event to position the mouse to where you had moved the cursor to.
    for example
    1.the mouse is at point 100,100
    2. you move the cursor from your code to point 0,0
    3. the user starts to move the mouse
    4. you code gets that event and repositions the cursor to the last place where it was, that is at 0,0

  • Automated Screen Capture

    I was wondering, can anyone think of a way of automating a method of obtaining a screen capture for a list of websites? E.g. let's say I have a list of URLs and I want to get a screen capture of each webpage, does anyone know how I might go about doing it quickly?
    The only way I could think of doing it was using the Robot package to swtich to a web browser, take a screen capture, and then process the image.... I was just wondering if anyone could think of a neater way of doing it?
    many thanks
    BBB

    you said "I'm guessing java wouldn't be the best way to go. "
    I'm under the impression that java can do everything. The trick might be to find out how to do it.
    I
    'll propose one really bad and slow way to do it.
    There is already a swing component that will translate HTML code (that was gathered) into the actual web page.
    Now I believe there is a Robot API that will perform clicks of the keyboard and mouse and simulate an actual user at the computer.
    In this case , you could make it simulate the buttons to do a print screen .
    You could use the robot API to make it paste the result some place and do whatever transformations and saving of the object needed.
    I realize this is a bad way to do it because it is so slow. But it is automated.
    However I am under the impression there is a way to do this effectively and very fast with java.
    I'm guessing it would be using the new nio package in java 1.4
    stephen

Maybe you are looking for

  • 10.4.2 will not load

    I have a g5 iMac 2.1ghz 20" that i've owned since new. It's being given to a family member and I wanted them to start out with a clean slate. I copied everything I wanted to my new iMac, and then broke out the original install disks - 10.4.2, that ca

  • Portege R30-A freezes in Sleep Mode

    Toshiba Portege R30-A My laptop is only about a month and a half old and ever since I got it, every once in a while when I go into sleep mode it freezes. It acts like its sleeping, the screen goes black, but the power and HD indicator lights are stil

  • Creating more room in a photo

    Hi, As you'll see in the attached, the layout looks top heavy because there is not nearly as much room below the lightbulb as there is above it. Isn't there a way to make a selction of a piece of the bottom (or top), flip it and then paste a few time

  • Attaching File While Sending Mail

    Dear All,             I want to send mail through sap for that i have used function module 'SO_NEW_DOCUMENT_SEND_API1'. Can anybode tell me how can i attach file in this mail. Regards, Mayank

  • Presets. Looking for Soft Glow, Color Pop, and Artistic Sketch

    Does anyone know how I can get the presets for my version of lightroom to have Color pop, artistic sketch in color and B&W, vintage, and soft glow? I am new to Lightroom but I have seen these effects used so I purchased lightroom and these effects ar