*
The moose likes Swing / AWT / SWT and the fly likes Capturing Screen Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Capturing Screen" Watch "Capturing Screen" New topic
Author

Capturing Screen

vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
Hi Java Lovers

I am using Robot class for capturing image which captures the screen as PrintScreen Command in our keyboard

The problem is :

It takes the screenshot of curent screen(all parts if some small sixe appl. are also open)

I am running my one of automated application in IE

The program will capture IE only if it is current window

I dont want this dependency .Is there any way to pass the parameters that this particular window should be captured

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

You specify the part of the screen to capture using the Rectangle. If you need to capture a specific window then you need to know the bounds of that window. Bad news - you're not going to do this with only Java. You'll need a bit of JNI for this.

Fortunately for you I've already written a non-Java program that uses the Windows API to do similar things, so I can tell you the native calls to use:
- EnumWindows to go through all the windows on your system
- GetWindowText to, for a window handle, get its caption (you could use this to filter on)
- GetWindowThreadProcessId to, for a window handle, get its process ID (you could use this to filter on)
- GetWindowRect to, for a window handle, get its bounds


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
can you please send me the code....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

We are NotACodeMill. Besides, it's C# and Delphi code, and you'd want to use C code for this.
vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
I was talking about the non-java program which you have used !!!
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4531
    
    5

So is Rob.


luck, db
There are no new questions, but there may be new answers.
vineet kumar chaudhry
Ranch Hand

Joined: Apr 02, 2011
Posts: 45
Sorry Rob

I got you know
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19682
    
  20

Here are the MSDN pages about these functions:
EnumWindows
GetWindowText
GetWindowThreadProcessId
GetWindowRect
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Capturing Screen