1

我正在为需要使用通用访问(可访问性和事件点击)的 OSX 开发实用程序。

我正在使用 AXIsProcessTrustedWithOptions 来检查应用程序是否被允许。我每秒检查一次此状态(池),以检测用户何时允许它。

不幸的是,AXIsProcessTrustedWithOptions 总是返回 false,即使应用程序已被允许。

我知道这是可能的,因为像 popclip 这样的其他应用程序正在这样做,但我无法弄清楚我做错了什么。

补充:代码

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:(id)kCFBooleanTrue, kAXTrustedCheckOptionPrompt, nil];
if (!AXIsProcessTrustedWithOptions((CFDictionaryRef)options) ) {
    while (!AXIsProcessTrustedWithOptions(NULL)) {
        NSLog(@"Still not allowed");
        [NSThread sleepForTimeInterval:1.0f];
    }
    NSLog(@"user just allowed the application");
}
else
{
    NSLog(@"App is already allowed");
}
4

0 回答 0