When trying to take a screenshot of vmware machine the inside of it is being blacked out for some reason.
Where as I expect to see the following:
The code seems to work fine when testing on calculator and few other applications, what could be causing this issue?
import win32gui
import win32ui
import win32con
def backgroundScreenshot(hwnd, width, height):
wDC = win32gui.GetWindowDC(hwnd)
dcObj=win32ui.CreateDCFromHandle(wDC)
cDC=dcObj.CreateCompatibleDC()
dataBitMap = win32ui.CreateBitmap()
dataBitMap.CreateCompatibleBitmap(dcObj, width, height)
cDC.SelectObject(dataBitMap)
cDC.BitBlt((0,0),(width, height) , dcObj, (0,0), win32con.SRCCOPY)
dataBitMap.SaveBitmapFile(cDC, 'test.bmp')
dcObj.DeleteDC()
cDC.DeleteDC()
win32gui.ReleaseDC(hwnd, wDC)
win32gui.DeleteObject(dataBitMap.GetHandle())
title="Win10_64 - VMware Workstation 16 Player (Non-commercial use only)"
hwnd = win32gui.FindWindow(None, title)
print(hwnd)
backgroundScreenshot(hwnd, 900, 780)