[python-win32] Absence of PrintWindow?
CAshurst at thig.com
Wed Dec 19 16:56:18 CET 2007
Thank you, that's essentially what I've ended up doing :)
Just in case anyone is attempting to do the whole "screenshot of hidden
window" thing, this is my base code (Inside wx, but it could just have
easily been straight win32api/gui):
from ctypes import windll
# Retrieved from a random window with win32gui.EnumChildWindows(...)
hwnd = 2885072
# Window_FromHWND appears in wxPython 18.104.22.168+
window = wx.Window_FromHWND(None, hwnd)
src_dc = wx.WindowDC(window)
width, height = window.GetSize()
mem_dc = wx.MemoryDC()
bitmap = wx.EmptyBitmap(width, height)
windll.user32.PrintWindow(hwnd, mem_dc.GetHDC(), 0)
image = bitmap.ConvertToImage()
filename = "testsnap.png"
Again, thanks for pointing me at ctypes - I was beginning to go crazy at not
finding a way around not having PrintWindow :D
From: Tim Golden [mailto:mail at timgolden.me.uk]
Sent: Wednesday, December 19, 2007 09:32
To: Chris Ashurst
Cc: PyWin32 Users List (E-mail)
Subject: Re: [python-win32] Absence of PrintWindow?
Chris Ashurst wrote:
> This is all a really long-winded (my apologies) way of asking if
> *is* in Pythonwin, and if not, that's fine - I just need to save my sanity
> from hunting for something that isn't there :)
> (The only reference I could find to PrintWindow in regards to the win32
> being wrapped was from a mailing list thread for Tcl in 2006 - the author
> mentions it isn't wrapped due to CPU concerns).
I don't think it's wrapped by pywin32. You should be able to
get to it with ctypes.
CONFIDENTIAL NOTICE: This email including any attachments, contains
confidential information belonging to the sender. It may also be
privileged or otherwise protected by work product immunity or other
legal rules. This information is intended only for the use of the
individual or entity named above. If you are not the intended
recipient, you are hereby notified that any disclosure, copying,
distribution or the taking of any action in reliance on the contents
of this emailed information is strictly prohibited. If you have
received this email in error, please immediately notify us by
reply email of the error and then delete this email immediately.
More information about the python-win32