Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For your original question, here it goes.</p> <p>Capturing an inactive window in Windows is pretty straightforward, using the robot class, ONLY and ONLY if the window is visible at the moment of capturing. <strong>If you want to avoid that requirement, you HAVE to use the DWM API.</strong></p> <p>Using the normal Windows API (pre Vista), you can use GetWindowRect(handle,RECT) where handle is a handler to the window you want to capture. This will get you a RECT object (I assume you are using JNA), here is the sequence of code you should write:</p> <pre><code>RECT dimensionsOfWindow = new RECT(); GetWindowRect( handlerToWindow, dimensionsOfWindow );//now in the dimensionsOfWindow you have the dimensions Robot robot = new Robot(); BufferedImage img = robot.createScreenCapture( dimensionsOfWindow.toRectangle() );//now in the img object you have only the image of your desired window </code></pre> <p>However!! This will work as a charm ONLY if your window is currently visible. If it is minimized, you will get some exception in java (because it has negative x and y ). And if it is partially hidden, you will also screenshot the other windows that are on top of it.</p> <p>You can't solve your problem on boxes that don't have dwm (Desktop Windows Manager) as it has an API that allows different windows to write to a temp buffer before they actually are painted to the screen. </p> <p>On XP and non - running DWM machines, however, you are stuck with the code I gave you.</p> <p>Additionally , you can take a look at the following question: <a href="http://bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx" rel="nofollow" title="Guide">link text</a></p> <p><strong>Edit:</strong></p> <p>Here is an interesting guide (in C#, though, but you can use JNA+Java applying the same principles) that will give you a better understanding of the DWM and how to use it to do EXACTLY what you want.</p> <p><a href="http://bartdesmet.net/blogs/bart/archive/2006/10/05/4495.aspx" rel="nofollow" title="Guide">link text</a></p> <p><strong>EditEdit</strong> Just saw you have a link to the same guide in C# that I gave you. What seems to be the problem in just rewriting the code for Java/JNA?</p> <p><strong>EditEditEdit</strong> To answer your additional question (how to convert your BitBit to a BufferedImage ), here is a guy who did it in his Open Source project. It is a nice piece of work and give him some appreciation:</p> <p><a href="http://code.google.com/p/jmemoryeditorw/" rel="nofollow">http://code.google.com/p/jmemoryeditorw/</a></p> <p>You might notice that if you run the program, it will give you all the processes and also...their Icons. <strong>If you dig in the code, you will see how they are converted from BitBit to BufferedImages.</strong></p> <p>Cheers and I have to say, a very nice question.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload