python-pillow / Pillow

Python Imaging Library (Fork)
https://python-pillow.org
Other
12.21k stars 2.22k forks source link

ImageGrab.grab() doesn't ignore windows layered on top (tooltip, pop-ups, etc.) #8456

Open a-alak opened 1 week ago

a-alak commented 1 week ago

What did you do?

Run PIL.ImageGrab.grab() without arguments.

What did you expect to happen?

Until now this has not included pop-ups and tooltips in the screenshot. I just updated to windows 11. I can see in issue #2569 that it is the expected behavior to not include layered windows, and that the option to include them was added, but not as a default.

I suppose the underlying API has changed in windows 11. Anyone that can share some knowledge about this?

What are your OS, Python and Pillow versions?

--------------------------------------------------------------------
Pillow 10.4.0
Python 3.10.5 (tags/v3.10.5:f377153, Jun  6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]
--------------------------------------------------------------------
Python executable is C:\Users\Public\SPEDA\env\Scripts\python.exe
Environment Python files loaded from C:\Users\Public\SPEDA\env
System Python files loaded from C:\Program Files\Python310
--------------------------------------------------------------------
Python Pillow modules loaded from C:\Users\Public\SPEDA\env\lib\site-packages\PIL
Binary Pillow modules loaded from C:\Users\Public\SPEDA\env\lib\site-packages\PIL
--------------------------------------------------------------------
--- PIL CORE support ok, compiled for 10.4.0
--- TKINTER support ok, loaded 8.6
--- FREETYPE2 support ok, loaded 2.13.2
--- LITTLECMS2 support ok, loaded 2.16
--- WEBP support ok, loaded 1.4.0
--- WEBP Transparency support ok
--- WEBPMUX support ok
--- WEBP Animation support ok
--- JPEG support ok, compiled for libjpeg-turbo 3.0.3
--- OPENJPEG (JPEG2000) support ok, loaded 2.5.2
--- ZLIB (PNG/ZIP) support ok, loaded 1.3.1
--- LIBTIFF support ok, loaded 4.6.0
*** RAQM (Bidirectional Text) support not installed
*** LIBIMAGEQUANT (Quantization method) support not installed
*** XCB (X protocol) support not installed
--------------------------------------------------------------------
radarhere commented 1 week ago

Could you attach an image to show what you're seeing?

a-alak commented 1 week ago

Yeah sorry, what i tested on was sensitive data, so i could not share. But here is an alternative example with the file explorer. Example 1 shows a tooltip with the url of the Outlook shortcut. Usually i would have expected the tooltip not to show in the screenshot like example 2.

exmple1 example2

radarhere commented 2 days ago

@nulano did you have any insight here?

nulano commented 2 days ago

I can confirm that tooltips are included with both include_layered_windows=False and include_layered_windows=True on Win 11 Pro version 23H2, but also on Win 10 Home version 22H2.

I just updated to windows 11.

Do you know which build of Win 10 you were running before you upgraded?

a-alak commented 8 hours ago

Unfortunately not. And honestly I am more challenged by popups than tool tips, and I cannot show you an example pic of the pop up. It is running on a hospital system, where there often is weird pop up messages. They did not use to show up in ImageGrab, but now they do.