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

Similar Messages

  • 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

  • Image Capturing for DnD via Robot

    Ladies n Gents
    I am attempting to enhance the drag and drop functionality of a certain jtable. Most of it works quite nicely, except, when I drag a row with no data; the image of the component physically under the jtable is captured and not of the row.
    For example, if the jtable appears on top of jbuilder, when I attempt to drag a empty row (row with no data), a portion of Jbuilder is captured.
    Is there a way to eliminate this unwanted behaviour? A related question may be, is there a way to capture a portion of the screen without using the robot class?
    Any links, ideas, suggestions are appreciated.
    Cheers

    thanks again for all the contributions.
    The beta player is a SONY BVW-75P.(http://www.videoplusfrance.com/fiche_location/134/magnetoscope--betacam-sp.htm)
    The video outputs i have at the back are:
    _1
    _2 (COMP/NON COMP)
    _3 (SUPER)
    _Ref Video
    _component 2 (Y/R-Y/B-Y)
    All of these are bnc outputs.
    I also have one dub/component 1 output.
    Audio is coming out of channel 1 and 2 of the audio output via xlr/rca adapters.
    I've started dubbing directly to DVCAM tapes because i still can't get the non-controlable device capture to work.
    i've looked as you suggested for an s-video output but can't find one on the deck. So right now video is outputting to the dsr through "Video output 1" with a BNC/RCA adapter.
    The dsr is set to video.
    As far as the beta deck settings go, i have
    TBC control set to local.
    TBC - bypass
    Video input - auto
    Rec inhibit - on
    Capstaan lock - 2fd
    Input select - composite
    The firewire works with the dsr no problem. I can capture the DV tape is just dubbed with no trouble.
    But just still can't capture now directly from the betasp deckk.
    cheers,
    tee.

  • 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

  • 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.

  • Taking screenshot with java applet using java robot class not working

    Hi Everyone,
    I am using the java applet to take screenshot of the web browser using the java's robot class.
    Robot objRobot = new Robot ();
    BufferedImage objBufferedImage = objRobot.createScreenCapture(objRectArea);
    The thing work good in windows system taking screenshot but in case of mac osx i get the blank image.When i check the event viewer in mac osx i get the following error.
    invalid context
    invalid pixel format
    CoreAnimation: rendering error 506
    The problem is coming for all the browser safari,firefox and chrome.My applet is signed applet.
    What might be the reason.An early reply is very valuable.
    My machine configuration is as follows.
    OS : MAC OSX
    Version : 10.6.4
    Is that a system level issue , java plugin issue?I'am confused with this error.
    Thanks sagar.

    870613 wrote:
    invalid context
    invalid pixel formatHm, seems like the Mac implementation of the Robot class is doing some bad initializations there. I can't be a 100% sure of course, but this smells like a bug to me. Are you sure you have the latest version of Java installed?

  • Alternative to Robot class

    hi have anyone an idea how can i make screenshoot from my scene without the class robot?
    at moment i use the Robot class to make screenshoots from my sceene
    Rectangle screenRect = new Rectangle(20,10,800,600);
             try{
                  Robot robot = new Robot();
                  BufferedImage image = robot.createScreenCapture(screenRect);
                  ImageIO.write(image, "png", new File(fileName));               
             } catch (AWTException e1) {}
                          catch (IOException e) {}         thats the code to make screenshoots but i think its not good to use AWT

    That depends: when modularity kicks in (Java 9 with early availability in Java 8?) you may end up with some light JVMs tailored for JavaFX-only without any AWT / Swing support. And if you are not connected to the Net (which is more common than you may think) you may not be able or want* to download the extra module(s) that give AWT / Swing support.
    *slow speed with limited amount size, expensive data plan, device without enough storage.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Robot class not working

    I need to make a macro with the robot class that draws a picture in a paint program. For each color in the image (256 colors total) it should change the paint color and drawing each 2x2 pixel that's that color. I made the program and it works correctly for about an hour, but then it starts slowing down a LOT, entering the wrong color codes, and drawing single pixels instead of 2x2.
    Here is the code for changing the color:
    robot.mouseMove (535, 504);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);
    robot.mouseMove (568, 410);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);
    for (i = 0; i < 6; i++)
        robot.keyPress (color.toUpperCase ().charAt (i));
    robot.keyPress (KeyEvent.VK_ENTER);
    robot.keyRelease (KeyEvent.VK_ENTER);Here is the code for drawing each pixel:
    robot.mouseMove (415 + (w * 2), 185 + (h * 2) - 1);
    robot.mousePress (InputEvent.BUTTON1_MASK);
    robot.mouseMove (415 + (w * 2), 185 + (h * 2) + 1);
    robot.delay (100);
    robot.mouseRelease (InputEvent.BUTTON1_MASK);Does anyone know why the robot stops working after about an hour?

    I'll guess that this might have something to do with it:
    for (i = 0; i < 6; i++)
        robot.keyPress (color.toUpperCase ().charAt (i));
        //need to release the key!
        robot.keyRelease (color.toUpperCase ().charAt (i));
    }Also, about your code to draw one pixel: it draws three pixels in a vertical line, at least in my paint program.

  • Image capture from avi vfw device can't find video modes

    Hello
    Here my issu, i have implemented image capture from a video device using jmf 2.1.1e performancepack, using a webcam everything is fine but when i use the video capture source i want to use i can only work with format 720x480 pal and i require 720x576 pal.
    jmf seem not to reconize video format from this source, but the video is correcty displayed and image correctly captured. I'm surprised it is half working:decoding&render is ok to but not format choice.
    I have check it is not because i'm in ntsc mode (ntsc is 720x480) because my analogic source is pal and color are correct (if with device software i change to ntsc mode i have a black&with but using jmf i'm in color so i'm in pal mode)
    Difference bettween the webcam and my device is that my device is an avi encoder so in jmf webcam is javax.media.format.YUVFormat and my device com.sun.media.format.AviVideoFormat
    i have tried many thing:
    install codec pack (divx6, another codec pack)
    try to use Fobs4JMF
    register in JMStudio IBMdecoder, jffmpeg
    Tanks for any help
    the device support many configuration UYVY 235x288 352x576 .... 720x576 but JMF offer only 1 video mode for this device.
    here in jmf my capture device info:
    Name = vfw:Microsoft WDM Image Capture (Win32):0
    Locator = vfw://0
    Output Formats---->
    0. com.sun.media.format.AviVideoFormat
    UYVY, 720x480, Length=691200 0 extra bytes
    and with a web cam:
    Name = vfw:Microsoft WDM Image Capture (Win32):0
    Locator = vfw://0
    Output Formats---->
    0. javax.media.format.YUVFormat
    YUV Video Format: Size = java.awt.Dimension[width=640,height=480] MaxDataLength = 460800 DataType = class [B yuvType = 2 StrideY = 640 StrideUV = 320 OffsetY = 0 OffsetU = 307200 OffsetV = 384000
    1. javax.media.format.RGBFormat
      RGB, 160x120, Length=57600, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=480, Flipped
    2. javax.media.format.RGBFormat
      RGB, 176x144, Length=76032, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=528, Flipped
    3. javax.media.format.RGBFormat
      RGB, 320x240, Length=230400, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=960, Flipped
    4. javax.media.format.RGBFormat
      RGB, 352x288, Length=304128, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=1056, Flipped
    5. javax.media.format.RGBFormat
      RGB, 640x480, Length=921600, 24-bit, Masks=3:2:1, PixelStride=3, LineStride=1920, Flipped
    6. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=160,height=120] MaxDataLength = 28800 DataType = class [B yuvType = 2 StrideY = 160 StrideUV = 80 OffsetY = 0 OffsetU = 19200 OffsetV = 24000
    7. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=176,height=144] MaxDataLength = 38016 DataType = class [B yuvType = 2 StrideY = 176 StrideUV = 88 OffsetY = 0 OffsetU = 25344 OffsetV = 31680
    8. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=320,height=240] MaxDataLength = 115200 DataType = class [B yuvType = 2 StrideY = 320 StrideUV = 160 OffsetY = 0 OffsetU = 76800 OffsetV = 96000
    9. javax.media.format.YUVFormat
      YUV Video Format: Size = java.awt.Dimension[width=352,height=288] MaxDataLength = 152064 DataType = class [B yuvType = 2 StrideY = 352 StrideUV = 176 OffsetY = 0 OffsetU = 101376 OffsetV = 126720[/i]

    I have find some information at l'article http://archives.java.sun.com/cgi-bin/wa?A2=ind0111&L=jmf-interest&P=22779
    but i didn't find "sample programs on the JMF Solutions page" which is about VFWDeviceQuery
    so i have trouble with point 2 so this article.
    I have try to rewrite VFWDeviceQuery:
    i just have add dimension 720x576 and "UYVY" in the variable declaration, then compile and replace VFWDeviceQuery .java in jmf.jar in but it is not working)
    I miss information on what to do on VFWDeviceQuery to try more
    About jmf soucre file, i have used the source file jmf-2_1_1e-scsl-src but i have some package missing such as com.ibm.media.codec.audio.BufferedEncoder ...
    so i can't use debugger on all jmf package and check how VFWDeviceQuery is working.
    if someone have information about please help me:
    - "sample programs on the JMF Solutions page" about VFWDeviceQuery
    - how to rewrite VFWDeviceQuery to support UYVY
    - how to compile entier jmf source files
    V.

  • Image Capture scans the whole bed?

    How can I set Image Capture to scan only the document?
    It scans the whole scanning bed and is adjusting my printed page so that it shrinks the image terribly. I make doll patterns so this is important to me to scan close to the size I draw. We can do it on my husband's windows laptop *shudder* but not my brand new Apple computer.
    This is the least user-friendly system I've used since I bought my first Apple computer in 1993.

    Cannot healp with a Robot, but Selenium is made to run automated test on web application by launching IE or Firefox and interacting with it. All tests are made possible by writing a JUnit Test (an extened version from Selenium).
    Selenium (http://www.openqa.org/selenium/) allow you to take a snapshot of the page being currently tested : you can keep a trace of nightly run tests on a server. Note you can test whatever you want, either your own pages or Google or whatever.com.

  • Why robot class doesnt get cursor

    i am using robot class , when i use createScreenCapture
    method it gets the everything on the screen but not the cursor.
    why? can i create i image that also get the cursor?
    many thanks

    MouseEvent provides a method:
    public Point getPoint()
    that returns the x,y position of the event relative to the source component.
    I guess it must be the archiect's view that the cursor is not a the screen, rather a device that points to the screen.
    -Merwyn
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support

  • Robot class slowing down

    I am using the robot class to make a macro that moves and clicks the mouse for a few hours. At first, the macro works correctly, and completes about five runs per second. However, after a few minutes the macro starts slowing down, and after an hour it is running through once every 10 seconds. Every run is exactly the same, so why could it be slowing down?

    Here's exactly what it's doing:
    1. get the color of the next pixel in a BufferedImage.
    2. make a robot and have it type the RGB values of the pixel into another window.
    3. move the mouse and click it a few times.
    I'm not using the hard drive. I'm not searching anything. I am not copying anything. Every run is exactly the same. Why is it getting slower as it runs? It finishes about a quarter of the image in 5 minutes, then hours later it has only done a few more rows.

  • Image Capture problem(blank picture)

    hi, I am new to JMF and I have refer and read some of the tutorial of JMF. then I try with the image capture program but unlucky it's not success. I was able to success to compile the program and get an empty picture.The picture is blank when use.
    here is my code so I hope i can get some advice on it. thank you
    public class imageCapture extends Panel implements ActionListener{
    public static Player player = null;
    public CaptureDeviceInfo di = null;
    public MediaLocator ml = null;
    static Buffer buf = null;
    static Image img = null;
    public VideoFormat vf = null;
    static BufferToImage btoi = null;
    public imageCapture()
    String str1 = "vfw:Microsoft WDM Image Capture (Win32):0";
    di = CaptureDeviceManager.getDevice(str1);
    ml = di.getLocator();
    try
    player = Manager.createRealizedPlayer(ml);
    player.start();
    Component comp;
    if ((comp = player.getVisualComponent()) != null)
    add(comp);
    catch (Exception e)
    public static void main(String[] args)
    imageCapture imgc = new imageCapture();
    // Grab a frame
    FrameGrabbingControl fgc = (FrameGrabbingControl) player.getControl("javax.media.control.FrameGrabbingControl");
    buf = fgc.grabFrame();
    // Convert it to an image
    btoi = new BufferToImage((VideoFormat)buf.getFormat());
    img = btoi.createImage(buf);
    // save image
    saveJPG(img,"c:\\pic123.jpg");
    player.close();
    public static void saveJPG(Image img, String s)
    BufferedImage bi = new BufferedImage(500, 400 , BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage(img, null, null);
    FileOutputStream out = null;
    try
    out = new FileOutputStream(s);
    catch (java.io.FileNotFoundException io)
    System.out.println("File Not Found");
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(bi);
    param.setQuality(0.5f,false);
    encoder.setJPEGEncodeParam(param);
    try
    encoder.encode(bi);
    out.close();
    catch (java.io.IOException io)
    System.out.println("IOException");
    public void actionPerformed(ActionEvent e) {
    throw new UnsupportedOperationException("Not supported yet.");
    }

    Could be any number of things... most likely, it's just trying to capture an image before the webcam is setup and running.
    Try putting in a wait statement (thread.currentthread.sleep) after you start the player to make it wait for, say, 5 seconds...see if that changes the output.

  • Canon MP560 no longer recognized by Image Capture/Preview

    I have a Canon MP560 wireless printer/scanner and for some reason the scanner can no longer be seen by either Image Capture, Preview, or the Canon mp560 scanner toolbox under the Print menu. This happened either after installing 10.6.5 or after installing the latest Canon Printer Driver updates (I am not sure which caused it, as I did both updates recently...)
    It can, however, be seen by MP Navigator 3.0.
    Anyone found a fix for this yet?
    thanks

    Okay, have done some testing and found some interesting things.
    With a new install of 10.6.5 (selecting not to add any printers) I was not able to locate any Canon AIO via wireless. The Default Add Printer pane was empty so it looks like the printer and scanner driver needs to be present on the Mac. For the printer this is understood, as the Canon protocol 'canonijnetwork' is not present in the BJPrinters folder located in Library > Printers > Canon (due to the customized installation the Canon folder was not even present). In checking the Image Capture folder (HD > Library) I also found that the Devices folder was missing. Inside of here you would normally find the Canon IJScanner package/s for a standard installation of 10.6. But with the customized install this package was not present and appears to influence the Mac's ability to 'see' the networked scanner component. To confirm this, I installed the Canon v2.4.1 driver update, which in turn created the Devices folder in Image Capture and consequently made the scanner component appear in the Default Add Printer view.
    Another observation was that prior to installing the Canon v2.4.1 update, Image Capture would still display the MP on the network, but under the Shared menu - not the Devices menu. So even without the ICA driver installed nor the MP scanner driver installed, I was still able to use Image Capture to scan a document from the wireless MP. The same was true for Preview in as far as the Networked Scanner selection showed all the MP's present on the wireless network.
    At this stage I believe that the Canon driver update you mentioned may have contributed to part, if not all, of your current symptom. The install.log does have a record of what this update installs. If you checked it there may be record of the installer not completing correctly. In any case I assume that for your Mac this update did not complete correctly and is causing the problem. So one suggestion would be to run the [Canon Driver v2.4.1 update|http://support.apple.com/kb/DL899] again (or for the first time if you simply used Software Update previously) to see if this repairs the CanonIJScanner packages.

  • Where did my scanner go? It disappeared from Image Capture

    I've been using Image Capture for quite awhile (since HP didn't upgrade their drivers to Lion probably), and suddently, even though my MacBook Pro is on the same wireless network as the printer/scanner (as they have been) the scanner is not showing up in Image Capture. But I can still print. And my dad is still able to scan from his PC to this same scanner. Any thoughts on how I can get it to show up again and start scanning? It's an HP Photosmart C7280.

    Restart the Mac.
    Turn off the scanner then turn it back on.
    Launch Image Capture.
    Click Shared top left side of the Image Capture window then click Show then click your printer name.
    It should start scanning.

Maybe you are looking for