Solved

Java robot class capturing black/blank desktop images - Help

Posted on 2007-03-25
9
1,603 Views
Last Modified: 2013-12-29
I am currently capturing various images from the desktop using the robot class. Yet every now and again my program will take a completely black image, which renders my program useless. Does anyone have any suggestion why this is happening ? and what I can do prevent or fix it ?

At the moment I just restart my computer and it seems fine, but I don't want this to happen on my clients computer.

Thanks
0
Comment
Question by:mr_mooray
9 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 18787711
How are you running the Robot?
0
 

Author Comment

by:mr_mooray
ID: 18787773
     try {
                  Robot robot = new Robot();

                  //capture a screenshot of desktop size
                  Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit()
                              .getScreenSize());
                  BufferedImage capture = robot.createScreenCapture(captureSize);

                  //save to file
                  ImageIO.write(capture, "bmp", new File("C:/Desktop.bmp"));

                  //Set Desktop Image
                  desktopImage = capture;

            } catch (HeadlessException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            } catch (AWTException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            } catch (IOException e) {
                  // TODO Auto-generated catch block
                  e.printStackTrace();
            }
0
 
LVL 35

Expert Comment

by:TimYates
ID: 18787868
The screensaver hasn't kicked in has it?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 

Author Comment

by:mr_mooray
ID: 18787881
No all screen savers are disabled, it just returns a completely black image. I don't think its my code, do you think it could be a different program interfering ?
0
 
LVL 30

Accepted Solution

by:
Mayank S earned 250 total points
ID: 18788981
http://forum.java.sun.com/thread.jspa?threadID=465261&messageID=2142224 says createScreenCapture () is slow - try JNI.
0
 
LVL 3

Assisted Solution

by:stimpyjcat
stimpyjcat earned 250 total points
ID: 19397447

There are some instances where the robot (at least in its current implementation) is not capable of capturing the screen contents.   Some transparent windows, video, or other direct-to-hardware rendering may not be available for capture by the robot.  The capture will also be blank on w32 systems when effectively run as a service as the System user without desktop access.

If the capture is intermittently getting invalid results, then there's likely a bug in the capture.  One workaround would be to sample a few pixels to ensure the capture is not blank, re-capturing if the capture appears to have failed.

0
 
LVL 35

Expert Comment

by:girionis
ID: 19675493
mr_mooray,
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in approximately four days.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final disposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help.jsp#hs5

girionis
EE Cleanup Volunteer
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB Script to add site to Java Exception List 4 77
Windows 10 IE Certificate Issue 10 45
Problem to picture file 20 51
Facing this issue for maven proxy setting 2 11
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question