Me goal is to get get ss of window that need to be on background and not full screen but part of it.
Im using below code:
screen = config['USER']['screen']
hwnd = win32gui.FindWindow(None, screen)
gl = config['USER']['refillgl'].partition(', ')
dp = config['USER']['refilldp'].partition(', ')
begin = (int(gl[0]), int(gl[2]))
left, top = gl[0], gl[2]
right, bottom = dp[0], dp[2]
left = int(left)
top = int(top)
right = int(right)
bottom = int(bottom)
width, height = right - left, bottom - top
hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC = win32ui.CreateDCFromHandle(hwndDC)
saveDC = mfcDC.CreateCompatibleDC()
saveBitMap = win32ui.CreateBitmap()
# i know it not take full screen but only 150x150 square and also it still take it at top left corner and i dont want to
saveBitMap.CreateCompatibleBitmap(mfcDC, 150, 150)
saveDC.SelectObject(saveBitMap)
# i try swaping begin at first parametr with third, try only begin and still nothing
saveDC.BitBlt((0, 0), (width, height), mfcDC, begin, win32con.SRCCOPY)
# this part i use from comment from post i showed u above becouse when 3rd parametr was 1 it dont work, but with 3 it work(get the correct window)
result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 3)
saveBitMap.SaveBitmapFile(saveDC, 'nazwa.png')
mfcDC.DeleteDC()
saveDC.DeleteDC()
win32gui.ReleaseDC(hwnd, hwndDC)
win32gui.DeleteObject(saveBitMap.GetHandle())
I try using minwinpy from this post on stackoverflow to take part of screen but it wont work in my opinion becouse it lacks
result = windll.user32.PrintWindow(hwnd, saveDC.GetSafeHdc(), 3)
Then i try this post and it work but take ss from top left corner. I want it to start for example in 600, 700 and make square of 150x150