Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions desktopmagic/screengrab_win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,19 @@ def getRectAsImage(rect):
return _getRectAsImage(rect)


def getWindowAsImage(hwnd = None):
"""
Returns a PIL Image object (mode RGB) of a Window.

Raises L{GrabFailed} if unable to take a screenshot (e.g. due to locked
workstation, no display, or active UAC elevation screen).
"""
if hwnd == None:
hwnd = win32gui.GetForegroundWindow()
rect = win32gui.GetWindowRect(hwnd)
return _getRectAsImage(rect)


def saveScreenToBmp(bmpFilename):
"""
Save a screenshot of the entire virtual screen to a .bmp file. Does not
Expand Down