Created
May 7, 2024 13:22
-
-
Save thewh1teagle/ba62761d1fe4970128dfa21b51afa04d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use accessibility_sys::AXIsProcessTrustedWithOptions; | |
use core_foundation_sys::base::{CFRelease, TCFTypeRef}; | |
use core_foundation_sys::dictionary::{CFDictionaryAddValue, CFDictionaryCreateMutable}; | |
use core_foundation_sys::number::kCFBooleanTrue; | |
use std::ffi::CString; | |
use std::ptr; | |
fn main() { | |
let mut is_allowed = false; | |
unsafe { | |
let options = | |
CFDictionaryCreateMutable(ptr::null_mut(), 1, std::ptr::null(), std::ptr::null()); | |
let key = CString::new("AXTrustedCheckOptionPrompt").unwrap(); | |
let value = kCFBooleanTrue; | |
CFDictionaryAddValue(options, key.as_ptr().as_void_ptr(), value.as_void_ptr()); | |
is_allowed = AXIsProcessTrustedWithOptions(options); | |
CFRelease(options as *const _); | |
} | |
println!("Accessibility permission enabled: {}", is_allowed); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment