screencapturekit 11.1.1

Safe Rust bindings for Apple's ScreenCaptureKit framework - screen and audio capture on macOS
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
extern "C" {
    fn CGPreflightScreenCaptureAccess() -> bool;
}

pub fn screen_capture_allowed() -> bool {
    if std::env::var("SCREENCAPTUREKIT_LIVE_TESTS").as_deref() != Ok("1") {
        eprintln!("skip: set SCREENCAPTUREKIT_LIVE_TESTS=1 to run live capture tests");
        return false;
    }
    let allowed = unsafe { CGPreflightScreenCaptureAccess() };
    if !allowed {
        eprintln!("skip: Screen Recording permission is not granted to this process");
    }
    allowed
}