Open gusxodnjs opened 1 month ago
@gusxodnjs interested about it too, do you know what to put in entitlements.plist
and Info.plist
also for permissions?
Use this module
// screen_capture.rs
// Use the objc crate to work with Objective-C objects and runtime
extern crate objc;
// Import necessary parts from the objc crate
use objc::runtime::Object;
use std::os::raw::c_void;
// Declare the external functions from CoreGraphics framework
extern "C" {
// CGPreflightScreenCaptureAccess doesn't take parameters and returns a bool.
// True if the app either already has screen capture access or if the system
// version is earlier than 10.15. False otherwise.
fn CGPreflightScreenCaptureAccess() -> bool;
// CGRequestScreenCaptureAccess doesn't take parameters and returns a bool.
// True if the user grants permission or if the app already has permission.
// False if the user denies permission or if an error occurs.
fn CGRequestScreenCaptureAccess() -> bool;
}
/// Check if the user has already granted screen capture access or if the system
/// version is earlier than 10.15.
pub fn preflight_access() -> bool {
unsafe {
// Safety: Calling an external C function, considered unsafe in Rust
CGPreflightScreenCaptureAccess()
}
}
/// Request screen capture access from the user.
pub fn request_access() -> bool {
unsafe {
// Safety: Calling an external C function, considered unsafe in Rust
CGRequestScreenCaptureAccess()
}
}
When I try to screen capture in macos, I get a pop-up if I don't have permission. I want to replace this pop-up with my custom pop-up. Is there a way to look up the system's settings before this pop-up pops up? I already know that I can access tcc.db to verify permissions, but I couldn't access this db in my application.