79572387

Date: 2025-04-14 05:23:46
Score: 0.5
Natty:
Report link

An explaination of PrintWindowW

Right After this line in your code

compatible_dc.BitBlt((0, 0), (width, height), dc_object, (0, 0), win32con.SRCCOPY)

add

 ctypes.windll.user32.PrintWindow(hwnd, compatible_dc.GetSafeHdc(), 2)

instead of win32gui.GetClientRect(hwnd), use win32gui.GetWindowRect(hwnd)

This will cleanup the image that you are converting to a numpy array for OpenCV. As far as the offset, you're going to end up with a boarder around the window itself because of shadowing around the window that is actually part of the window as you can see there isn't any spacing along the top of the images below.

Before: Before

And after enter image description here

Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: phpjunkie