473,573 Members | 2,503 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Window capture using WM_PRINT and Python

arN
Hi !

I'm a Java developper and I wish to make a capture of an offscreen
window (on WinXP). It's not possible in Java, so I use a python script
and WM_PRINT, but it doesn't seem to work.

Could someone have a look at my script and give me any advise ?

TIA

--
Arnaud
my python script : python snap.py GraphicalContex t_handle image_handle
--------------------------------------------------------------------------------------------------
snap.py :
"
import win32api, win32con, sys

win32api.SendMe ssage(sys.argv[2], win32con.WM_PAI NT, sys.argv[3], 0)
win32api.SendMe ssage(sys.argv[2], win32con.WM_PRI NT, sys.argv[3],
win32con.PRF_CH ILDREN | win32con.PRF_CL IENT | win32con.PRF_OW NED)
"

------------------------------------------------------------------------------------------------
snippet from Snapshot.java :
"
public static Image snapshot(Compos ite bean) {
GC gc = new GC(bean);
final Image image = new Image (null, bean.getBounds( ).width,
bean.getBounds( ).height);
String commmand = "python snap.py " + gc.handle + " " + image.handle;

Runtime rt = Runtime.getRunt ime();
try {
Process p = rt.exec(command );
} catch (.....)

gc.dispose();
return image;
}
"
Jul 18 '05 #1
1 2328
Do you get any kind of traceback when you start a process that way?
There's not much info to go on.

Sys.argv parameters are passed as strings. You'll need to do an int() on
them
before you can use them as handles. Also, not all handles are portable
between processes. Your device context handle might not be valid
even if you make it an int.

hth
Roger
"arN" <pa*@demail.svp > wrote in message
news:41******** *************** @news.club-internet.fr...
Hi !

I'm a Java developper and I wish to make a capture of an offscreen window
(on WinXP). It's not possible in Java, so I use a python script and
WM_PRINT, but it doesn't seem to work.

Could someone have a look at my script and give me any advise ?

TIA

--
Arnaud
my python script : python snap.py GraphicalContex t_handle image_handle
--------------------------------------------------------------------------------------------------
snap.py :
"
import win32api, win32con, sys

win32api.SendMe ssage(sys.argv[2], win32con.WM_PAI NT, sys.argv[3], 0)
win32api.SendMe ssage(sys.argv[2], win32con.WM_PRI NT, sys.argv[3],
win32con.PRF_CH ILDREN | win32con.PRF_CL IENT | win32con.PRF_OW NED)
"

------------------------------------------------------------------------------------------------
snippet from Snapshot.java :
"
public static Image snapshot(Compos ite bean) {
GC gc = new GC(bean);
final Image image = new Image (null, bean.getBounds( ).width,
bean.getBounds( ).height);
String commmand = "python snap.py " + gc.handle + " " + image.handle;

Runtime rt = Runtime.getRunt ime();
try {
Process p = rt.exec(command );
} catch (.....)

gc.dispose();
return image;
}
"



----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3159
by: Catalin Lungu | last post by:
Hi, Can anybody help me to implement the following VB code in Python. Thanks in advance. Private Declare Function SendMessage Lib "user32.dll" Alias _ "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _ ByVal wParam As Long, ByVal lParam As Long) As Long Private Const WM_PAINT = &HF Private Const WM_PRINT = &H317
5
5619
by: Earl Eiland | last post by:
Anyone know how to capture text from GUI output? I need to process information returned via a GUI window. Earl
4
2380
by: Abhishek | last post by:
Hi All, how do I find the handle of a child window and get a screenshot of that in a hbitmap at present i tried the below method but am getting the screenshot of the desktop. the Egyptian Addiction is the name of the game and the mozillacontentwindowclass is the handle i need who's window i want to capture int nScreenWidth = 300; int...
0
1148
by: sixstorm | last post by:
Hi All, I would like to know how can I capture an ENTIRE webbpage in the .Net 2 WebBrowser control (not the ShDocVw Com Component) and turn it into a bitmap. I want the page to be captured beyond the scroll bars of the WebBrowser. I know that this is possible with some API calls (like GetDC or WM_PRINT), but I don't know how to use that. I am...
0
7668
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7983
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8179
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7735
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5257
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2166
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
992
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.