Sample Header Ad - 728x90

Can I stop macOS asking for screen recording permission while using mss.mss() in a python script?

1 vote
2 answers
289 views
I am trying to use mss to capture a portion of my screen using the following code:
import mss
import cv2
import numpy as np

monitor_region = {
    "top": 810,
    "left": 1070,
    "width": 660,
    "height": 300
}


def get_frame(display_frame=False):
    with mss.mss() as sct:
        # Capture a single frame
        img = sct.grab(monitor_region)

        # Convert to NumPy array and display
        frame = np.array(img)
        # print(frame)
        # print("frame dim = ", frame.shape)

        if display_frame:
            cv2.imshow("Captured Region", frame)
            cv2.waitKey(0)
            cv2.destroyAllWindows()
When running, my mac keeps prompting for permission and I have to click allow for every request. enter image description here Unfortunately, this isn't just a one-time thing, it happens for every screenshot request I make. This is not feasible when I am making multiple requests. Hence, I am looking for a way to disable this security check. I have allowed terminal full access to the disk, and to screen and audio recording in my system settings. This still didn't work so I am currently using pyautogui to automatically allow this, but this is still slow (takes ~0.2 seconds to get rid of) for my application. I am expecting a solution to guide me to disable the above security check. Is it possible to eliminate further requests? edit: output of the given command (
read ~/Library/Group\ Containers/group.com.apple.replayd/ScreenCaptureApprovals
):
{
    "/Applications/Shottr.app/Contents/MacOS/Shottr" =     {
        kScreenCaptureApprovalLastAlerted = "2125-06-05 15:25:33 +0000";
        kScreenCaptureApprovalLastUsed = "2125-06-05 15:25:33 +0000";
    };
    "com.apple.Terminal" =     {
        kScreenCaptureApprovalLastAlerted = "2125-06-05 15:25:33 +0000";
        kScreenCaptureApprovalLastUsed = "2125-06-05 15:25:33 +0000";
    };
}
Asked by tiny_sleasel (23 rep)
Jun 2, 2025, 11:34 PM
Last activity: Jun 6, 2025, 03:32 PM