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

Screen capture in MacOS #87

Closed
RandyHarr opened this issue Jun 9, 2021 · 6 comments
Closed

Screen capture in MacOS #87

RandyHarr opened this issue Jun 9, 2021 · 6 comments

Comments

@RandyHarr
Copy link

See https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos

A Mac-specific code, maybe in PIL or the Python Launcher itself, needs to be added to allow the app to request the screen capture permission BEFORE the code will work on Apple MacOS Catalina or later. As none of the other solutions work on all platforms (Linux, Win10, MacOS), it would be nice if you could get this fix pushed through (or integrated into your code if possible).

@ponty
Copy link
Owner

ponty commented Jun 15, 2021

I have no Mac, but I accept Mac-specific code if it is in the project's scope.

@ponty ponty closed this as completed Mar 11, 2023
@RandyHarr
Copy link
Author

RandyHarr commented Mar 26, 2023

Did find this objective C code method to accomplish it. But only shows use/ binding to javascript in chromium. How to bind into python? mac-screen-capture-permissions

Did make a request way back when on stackoverflow but no response there either. can-you-request-the-macos-screen-recording-permission-in-python

@ponty
Copy link
Owner

ponty commented Mar 26, 2023

I followed your links and the solution is here:

BoboTiG/python-mss#134

@RandyHarr
Copy link
Author

That "solution" is not a programmatic one. It requires a user to setup their MacOS System Preferences to allow the screen capture. See my comment at [How to check App permission in mac os | python which has a link to a user manual image I added which describes how to do that. But when do users ever look at the manual :)

As indicated in the post shown above, am looking for a programmatic solution. If even just to generate a pop-up to the user that they need to enable the permission. It appears the code to determine if the permission is there and the code to request the OS generate the pop-up to set the permission are pretty much one in the same. So it would be nice if pyscreenshot could use the Objective C code pointed to above. (Do not recall if you have the "pip" construct method to include binary libraries or Objective C code that is linked to python).

Python itself, or a terminal it starts from, do not ever cause this OS level pop-up when the screen capture is initiated from pyscreenshot inside a python program. So, today, a user never knows that this is an issue or that there is even an issue to resolve. Just the user gets blank screen captures.

@ponty
Copy link
Owner

ponty commented Apr 10, 2023

  • The goal of this library (README) "pure Python wrapper", so I won't add non Python code.
  • Checking system permissions and activating system dialogs seem to me out of scope. Ι know 2 other screenshot libraries: Pillow and python-mss. They should have the same problem. Do they think about such feature? I don't think so. In my opinion this feature should be implemented in your program or library, and you can call it before calling any of the screenshot libraries.

@ponty ponty reopened this Apr 10, 2023
@RandyHarr
Copy link
Author

The other mentioned Python libraries have not incorporated this MacOS change, MacOS applications are supposed to provide the pop-up to allow the user to change permissions. Unfortunately, the way Python is implemented, the pop-up is initiated for Terminal only and not the Python interpreter as well.

I believe the mentioned packages have non-Python code as part of their PIP installation; it becomes a requirement to have XCode installed on MacOS for some PIP library configures.

We are a pure python application on a very wide array of platforms (as it sounds like your package may be). So only chance for non-python code is in PIP-installed libraries. (We would simply distribute with BioConda but they do not support Windows which nearly 1/2 our users are on. So we do compile and distribute bioinformatic tools as a distinct and separate function at the moment. Once we get the msys package manager to include all we need; we will drop the separate port / distribution of Windows bioinformatics tools and likely distribute as BioConda on most platforms. Native Win executables are still faster than WSL2/G.)

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

No branches or pull requests

2 participants