As it says: the window is hidden. You can not make a screen shot of a
hidden
window 'cos it has no visual representation at the very moment. Simply
show it.
And if you do not want to see it while it's shown show it somewhere out
of the bounds of your virtual screen.
regards
Juergen
This will restore a minimized window, bring it to the top and save a bmp.
import time
import win32gui, win32ui, win32con, win32api
def window_capture(window_title):
hwnd=win32gui.FindWindow(None, window_title)
if not hwnd:
raise 'Window not found'
print hwnd
win32gui.ShowWindow(hwnd,win32con.SW_RESTORE)
win32gui.SetForegroundWindow(hwnd)
time.sleep(0.1)
l,t,r,b=win32gui.GetWindowRect(hwnd)
h=b-t
w=r-l
hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC=win32ui.CreateDCFromHandle(hwndDC)
saveDC=mfcDC.CreateCompatibleDC()
saveBitMap = win32ui.CreateBitmap()
saveBitMap.CreateCompatibleBitmap(mfcDC, w, h)
saveDC.SelectObject(saveBitMap)
saveDC.BitBlt((0,0),(w, h) , mfcDC, (0,0), win32con.SRCCOPY)
temp_dir=win32api.GetTempPath()
bmpname=win32api.GetTempFileName(temp_dir,'wc')[0]+'.bmp'
saveBitMap.SaveBitmapFile(saveDC, bmpname)
return bmpname
Roger