def window_capture_beat(hwnd,stayx:int,endx:int,stay:int,endy:int):
hwndDC = win32gui.GetWindowDC(hwnd)
mfcDC = win32ui.CreateDCFromHandle(hwndDC)
saveDC = mfcDC.CreateCompatibleDC()
saveBitMap = win32ui.CreateBitmap()
width = endx - stayx
height = endy - stay
saveBitMap.CreateCompatibleBitmap(mfcDC, width, height)
saveDC.SelectObject(saveBitMap)
saveDC.BitBlt((0, 0), (width, height), mfcDC, (stayx, stay), win32con.SRCCOPY)
signedIntsArray = saveBitMap.GetBitmapBits(True)
win32gui.DeleteObject(saveBitMap.GetHandle())
mfcDC.DeleteDC()
saveDC.DeleteDC()
win32gui.ReleaseDC(hwnd, hwndDC)
img = np.frombuffer(signedIntsArray, dtype="uint8")
img.shape = (height, width, 4)
return cv2.cvtColor(img, cv2.COLOR_RGBA2RGB)