python-mss
python-mss copied to clipboard
Capture single window
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
- We're using Polar.sh so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.
Not a dev here but here I have an idea on how this could be done.
- On Linux, use an interface for X11
- On Windows, use Win32GUI API
- On Mac, could use appscript
Find the Window size and position with the API, and use that as the mask for the screen capture.
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.
Is it possible to capture a single app window on OSX?
Looks like it https://stackoverflow.com/a/48030215
I meant, with this library using python.
No, that is what this issue is to request.
There is another project called screenshot
that you can use for that.
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.