Enable access for assistive devices programmatically on 10.9

前端 未结 9 2144
庸人自扰
庸人自扰 2020-11-27 11:27

I want to enable access for assistive devices programatically on 10.9. On 10.8 and lower I was using following Applescript to enable access for assistive devices:

         


        
9条回答
  •  天命终不由人
    2020-11-27 12:01

    I have found the following code snippet which properly requests Accessibility permissions in OS X 10.9:

    if (AXIsProcessTrustedWithOptions != NULL) {
        // 10.9 and later
        const void * keys[] = { kAXTrustedCheckOptionPrompt };
        const void * values[] = { kCFBooleanTrue };
    
        CFDictionaryRef options = CFDictionaryCreate(
                kCFAllocatorDefault,
                keys,
                values,
                sizeof(keys) / sizeof(*keys),
                &kCFCopyStringDictionaryKeyCallBacks,
                &kCFTypeDictionaryValueCallBacks);
    
        return AXIsProcessTrustedWithOptions(options);
    }
    
    // OS X 10.8 and older
    

提交回复
热议问题