[python-win32] Window capture using WM_PRINT and Python

Niki Spahiev niki at vintech.bg
Wed Jan 19 09:36:13 CET 2005


Cathie & Arnaud wrote:

> 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 ?  (That's 
> my first script in python, be kind !)
> 
> TIA
> 

import win32api, win32con, sys

# sys.argv[0] is script name
hwnd = int(sys.argv[1])
hdc = int(sys.argv[2])

win32api.SendMessage(hwnd, win32con.WM_PAINT, hdc, 0)
win32api.SendMessage(hwnd, win32con.WM_PRINT, hdc, win32con.PRF_CHILDREN 
| win32con.PRF_CLIENT | win32con.PRF_OWNED)

check that hdc is valid DC handle.

HTH
Niki Spahiev


More information about the Python-win32 mailing list