BoboTiG / python-mss

An ultra fast cross-platform multiple screenshots module in pure Python using ctypes.
https://pypi.org/project/mss/
MIT License
998 stars 88 forks source link

ScreenShotError("gdi32.GetDIBits() failed.") #209

Closed fidel-perez closed 1 year ago

fidel-perez commented 2 years ago

General information:

Description of the warning/error

The following piece of code is being called for ~6 hours, about once a minute. After 6 hours the error starts to be thrown. This has happened several times, it is a consistent situation. I have checked all the previous bug reports with the same issue and I don't see what could be happening.

with mss.mss() as sct:
    haystack_img = np.array(sct.grab(image_input))

Full message

  File "D:\Dropbox\git\img-testing\common_image_recognition.py", line 103, in extract_image_from_input
    haystack_img = np.array(sct.grab(image_input))
  File "C:\Python39\lib\site-packages\mss\base.py", line 88, in grab
    return self._grab_impl(monitor)
  File "C:\Python39\lib\site-packages\mss\windows.py", line 285, in _grab_impl
    raise ScreenShotError("gdi32.GetDIBits() failed.")

Other details

Thank you!

BoboTiG commented 1 year ago

It should be fixed in e3e9652bc0a459675361d18953d64863d033046f, and will be part of the version 9.0.0.