473,769 Members | 3,102 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 2339
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
3173
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
5626
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
2405
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 nScreenHeight = 225;
0
1158
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 using VB but I understand C# as well. Thanks
0
10222
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9999
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
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
2
3570
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.