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

PIL.ImageGrab.grab() doesn't "see" all windows #2569

Closed
shmarlovsky opened this issue Jun 8, 2017 · 5 comments · Fixed by #3808
Closed

PIL.ImageGrab.grab() doesn't "see" all windows #2569

shmarlovsky opened this issue Jun 8, 2017 · 5 comments · Fixed by #3808
Labels

Comments

@shmarlovsky
Copy link

shmarlovsky commented Jun 8, 2017

Code

im = PIL.ImageGrab.grab()
im.save('2.png')

Here is what actually displayed:
image

Here is the screenshot of PIL:
screenshot_27

Pillow version==4.1.0
This is relevant for different pop ups and menus.

According to @glitchassassin (from pyautogui):

Looks like this is a limitation of Pillow, using SRCCOPY instead of SRCCOPY | CAPTUREBLT in the call to BitBlt.

@hugovk
Copy link
Member

hugovk commented Jun 8, 2017

There's the SRCCOPY:

if (!BitBlt(screen_copy, 0, 0, width, height, screen, 0, 0, SRCCOPY))

@glitchassassin
Copy link

See BitBlt documentation:

CAPTUREBLT

Includes any windows that are layered on top of your window in the resulting image. By default, the image only contains your window. Note that this generally cannot be used for printing device contexts.

For the desktop window, "windows that are layered on top" include popups, tooltips, menus, and perhaps some other specialty windows that have to always appear in the foreground. OR-ing the CAPTUREBLT flag with the SRCCOPY flag guarantees that these windows will also be captured.

Note that not all applications may wish to capture these additional details, so for backwards compatibility, it may be worth adding an argument to the method definition to specify "capture overlays".

@edanca
Copy link

edanca commented Jul 23, 2018

Hello, I'm having the same problem, but I don't see any display.c file in the Pillow directory as hugovk mentioned and also didn't found the call to BitBlt.
I'm trying to screencapture with pyautogui and saw that not all the windows on the screen were captured and also saw that this could be an issue from pillow.

I've installed with pyautogui with PIP, and this only installs the PIL folder and not all the files in the parent directory, as it is here.
I have Pillow 5.2.0

Do you know how to fix this?

@radarhere
Copy link
Member

For the record, display.c is located at https://github.com/python-pillow/Pillow/blob/master/src/display.c. @edanca was likely having trouble finding it because it was moved into the 'src' directory since earlier comment.

@radarhere
Copy link
Member

I've created PR #3808 to address this.

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

Successfully merging a pull request may close this issue.

5 participants