[python-win32] How to take a snapshot of a specific control?
Ray Schumacher
rays at blue-cove.com
Mon Dec 11 20:02:01 CET 2006
Thanks for the reply,
At 08:06 PM 12/10/2006, Mark Hammond wrote:
> I'm trying to do a fast desktop capture myself, and having DC/pyDC
> confusion.
I'm not sure exactly what this means, but I'm guessing you are having
trouble with the pythonwin/win32ui GetSafeHdc objects, versus those
used by win32gui.
I'm generally confused by DC/pyDC, PyCDC, selecting and blitting..
The goal is to get a 640x480 RGB image data string from the screen
window that I can pass to pyMedia.
I've tried various permutations of the below lines, but I realize
that I really don't get the Windows DC/BMP/blit concepts: the order
that windows-handles-DCs-blits-selects-BMPs need to be created.
These lines all execute:
dtwnd = win32gui.GetDesktopWindow()
hdcSrc = win32gui.GetWindowDC(dtwnd)
hdcDestH = win32ui.CreateDCFromHandle(dtwnd)
hdcDest = win32gui.CreateCompatibleDC(hdcSrc)
hBitmap = win32gui.CreateCompatibleBitmap(hdcSrc, 1024, 768)
win32gui.SelectObject(hdcDest, hBitmap)
destHDC = hdcDestH.GetSafeHdc()
but I start having trouble with
hdcDestH.BitBlt((0, 0), (1024, 768), hdcSrc, (0, 0), 0x00CC0020)
TypeError: The 'O' param must be a PyCDC object
and on from there.
I can't say that I need anything from win32ui, since I don't know
what I need at all!
Thank you,
Ray
More information about the Python-win32
mailing list