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

Capture single window #194

Open stuaxo opened 3 years ago

stuaxo commented 3 years ago

There should be options to capture single windows.

There is complication here, as different strategies may not work in even within a single OS.

IMO where possible capture should not capture the whole screen clipped to the window, where possible it should use native APIs to grab just the window.

On windows, one example of this is here https://stackoverflow.com/questions/19695214/python-screenshot-of-inactive-window-printwindow-win32gui

It doesn't work for Modern UI apps, (so calculator does not work, but notepad does), where different APIs are needed, but it's probably better than nothing / a start ?

Upvote & Fund

Fund with Polar

sagarreddypatil commented 3 years ago

Not a dev here but here I have an idea on how this could be done.

Find the Window size and position with the API, and use that as the mask for the screen capture.

stuaxo commented 3 years ago

This can definitely be done.

I'm arguing against a mask + fullscreen capture where possible so that windows don't need to be moved to the front to be captured.

salonsoGH commented 3 years ago

Is it possible to capture a single app window on OSX?

stuaxo commented 3 years ago

Looks like it https://stackoverflow.com/a/48030215

salonsoGH commented 3 years ago

I meant, with this library using python.

stuaxo commented 3 years ago

No, that is what this issue is to request.

There is another project called screenshot that you can use for that.

archiif commented 3 years ago

Here's a Windows implementation of this feature from flexx (purely with ctypes): https://github.com/flexxui/flexx/blob/master/flexx/util/screenshot.py Though the comment says that it supports Linux, it seems that only the Windows part is implemented.