-
April 14th, 2010, 08:33 AM
#1
GetProcessesByName - Help grabbing java screenshot
Okay, I moved from using "FindWindow" to "GetProcessesByName". My main goal is to get a screenshot of a java applet embedded into an internet browser. I thought you could simply get the process handle to java.exe, then go "MainWindowHandle", however apparently this is not the case.
So the question is, how would I go about handling this. I wish to take a screenshot of this applet even if it's not currently in view. Thanks.
-
April 14th, 2010, 10:44 AM
#2
Re: GetProcessesByName - Help grabbing java screenshot
The first thing to do is get out the Spy++ tool and check out the window hierarchy and process for the java applet.
That will tell you what process you need to look for and, once you find the correct process, what the correct hierarchy is to get to the window you need to capture.
As far as being able to capture a window that isn't visible... That's going to be a no-op. In order to capture the window, it must be visible.
-
April 14th, 2010, 07:05 PM
#3
Re: GetProcessesByName - Help grabbing java screenshot
Well, the window heiarchy is Mozilla, UI class, UI class, UI class, SunAwtFrame, SunAwtCanvis, SunAwtCanvis exc.. Now I know a way to get a screenshot of a window when it is not on top, or hidden behind other windows. Though I'm not sure how to get the handle of that SunAwtCanvis class.
If anyone has an idea on how to get it, maybe using FindWindowEx, help would be appriciated.
-
April 14th, 2010, 07:25 PM
#4
Re: GetProcessesByName - Help grabbing java screenshot
Originally Posted by ADT_Clone
Now I know a way to get a screenshot of a window when it is not on top, or hidden behind other windows. Though I'm not sure how to get the handle of that SunAwtCanvis class.
If anyone has an idea on how to get it, maybe using FindWindowEx, help would be appriciated.
Let me try to say this again since you missed it the first time:
You can't take a screenshot of a window if it is covered by another window.
Typically you handle this by finding the window, move it to the top, and then take a screenshot of it.
-
April 14th, 2010, 08:07 PM
#5
Re: GetProcessesByName - Help grabbing java screenshot
Originally Posted by Arjay
You can't take a screenshot of a window if it is covered by another window.
In windows XP yes, but this might not be the case for Vista or Windows 7 since it uses a compositing window manager and has window previews.
-
April 14th, 2010, 08:37 PM
#6
Re: GetProcessesByName - Help grabbing java screenshot
Thank you Chris lol. I know it is possible to take a screenshot on Windows XP plus of a window behind another. Let me find the function:
[DllImport("user32.dll")]
private static extern bool PrintWindow(IntPtr hwnd, IntPtr hdcBlt,
uint nFlags);
It was a new addition to the Windows API.
-
April 15th, 2010, 12:44 AM
#7
Re: GetProcessesByName - Help grabbing java screenshot
Let me know how that works for you.
-
April 15th, 2010, 01:08 AM
#8
Re: GetProcessesByName - Help grabbing java screenshot
It doesn't work, that's why I've posted lol. I'm attempting to get the window handle for the java applet. However, when I try to get it from GetProcessByName("java"), it's MainWindowHandle is 0. So I don't actually know where I can find the window handle for the java applet.
-
April 15th, 2010, 01:44 AM
#9
Re: GetProcessesByName - Help grabbing java screenshot
What language are you coding in? Is it C#? If so, your in the wrong forum.
At any rate, did you use the spy tool? You should use the spy tool and its Find window to select the window you want. Next, in the "Windows" tab, you click on Parent Window until you reach the outermost parent window, next click on the "Process" tab to get the process id. Convert the hex pid to decimal and find the process id in task manager to get the name of the process.
In your case it may very well turn out to be "java" or "java.exe".
As far as MainWindowHandle being 0, this handle isn't always set properly. Use the spy tool to what class and title is used for the main window, then use EnumWindows to retrieve it (and filter it by the process id).
-
April 15th, 2010, 09:31 AM
#10
Re: GetProcessesByName - Help grabbing java screenshot
Originally Posted by ADT_Clone
Okay, I moved from using "FindWindow" to "GetProcessesByName". My main goal is to get a screenshot of a java applet embedded into an internet browser.
May I ask why you're attempting to do this, instead of just using a program similar to Snag-It or some other utility?
Regards,
Paul McKenzie
-
April 16th, 2010, 12:45 AM
#11
Re: GetProcessesByName - Help grabbing java screenshot
This is part of a program that will then do image analysis. I would like to make it easy for the user so they don't have to select the program. It will always be a java applet.
-
April 16th, 2010, 09:09 AM
#12
Re: GetProcessesByName - Help grabbing java screenshot
Thank you for the help. I actually found another resource and found that by using repeated FindWindowEx commands, I can actually get this java applet and take a screenshot.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|