File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Capturing Screen

 
vineet kumar chaudhry
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
vineet kumar chaudhry
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can you please send me the code....
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was talking about the non-java program which you have used !!!
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So is Rob.
 
vineet kumar chaudhry
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry Rob

I got you know
 
Rob Spoor
Sheriff
Pie
Posts: 20372
44
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are the MSDN pages about these functions:
EnumWindows
GetWindowText
GetWindowThreadProcessId
GetWindowRect
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic