Pillow ImageGrab not working on Steam window

39 Views Asked by At

I'm trying to create a program that is based a game that I am playing. However, whenever I open my game through Steam to test the program, the captured image freezes on the first frame. This only occurs whenever I open a game from Steam, it works perfectly fine in every other instance. Does anyone have any explanation or an idea of how to get around this?

this is the core code around my program, which runs into the same issue

import cv2
import numpy as np
from PIL import ImageGrab, Image
import pyautogui

x,y = pyautogui.size()

while True:
    ss = ImageGrab.grab(bbox=(x/2-250,y/2-250,x/2+250,y/2+250))
    cv2.imshow("", np.array(ss))

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cv2.destroyAllWindows()

I verified the screen capture works on everything else except for Steam games.

0

There are 0 best solutions below