Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdi32.GetDIBits() failed when two .grab() areas overlap #128

Closed
shrddr opened this issue Aug 20, 2019 · 2 comments
Closed

gdi32.GetDIBits() failed when two .grab() areas overlap #128

shrddr opened this issue Aug 20, 2019 · 2 comments

Comments

@shrddr
Copy link

shrddr commented Aug 20, 2019

General information:

  • OS name: Windows
  • OS version: 10
  • OS architecture: 64 bits
  • Resolutions:
    • Monitor 1: 1920x1080
  • Python version: 3.6.5
  • MSS version: 4.0.3

Description of the warning/error

Calling .grab in a loop twice with specific area configurations leads to gdi32.GetDIBits() failed after 4996..4998 loops

# ok
#area1 = {"top": 100, "left": 100, "width": 400, "height": 320, "mon": 1 }
#area2 = {"top": 200, "left": 200, "width": 320, "height": 320, "mon": 1 }  

# ok
#area1 = {"top": 50, "left": 7, "width": 300, "height": 300, "mon": 1 }
#area2 = {"top": 200, "left": 200, "width": 300, "height": 300, "mon": 1 }

# fail
area1 = {"top": 50, "left": 7, "width": 400, "height": 320, "mon": 1 }
area2 = {"top": 200, "left": 200, "width": 320, "height": 320, "mon": 1 }

i = 0
with mss.mss() as sct:
    while "Screen capturing":
        try:
            frame1 = sct.grab(area1)
            frame2 = sct.grab(area2)
            i += 1
        except mss.ScreenShotError as e:
            print("fail at:", i)
            raise e

After one fail, rerunning the same script produces same error immediately. Have to restart Python to make it work for 4996 more loops.

Full message

fail at: 4996
ScreenShotError: gdi32.GetDIBits() failed.

Other details

Same behaviour at machine with Windows 7, Python 3.7.0 and different monitor configuration

@BoboTiG
Copy link
Owner

BoboTiG commented Dec 26, 2019

Could you try to use the version from the master branch?

@BoboTiG
Copy link
Owner

BoboTiG commented Dec 30, 2019

It is fixed on master. I will release a new version in the week. Thanks for the report :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants