Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Implement the AXMakeProcessTrusted dance #4

Open
robrix opened this issue Jan 7, 2011 · 1 comment
Open

Implement the AXMakeProcessTrusted dance #4

robrix opened this issue Jan 7, 2011 · 1 comment

Comments

@robrix
Copy link
Owner

robrix commented Jan 7, 2011

  1. Request authorization to escalate privileges
  2. Escalate privileges
  3. AXMakeProcessTrusted()
  4. Relaunch

Relaunching should use some sort of callback mechanism or something so that client code can (for example) ask the user if they want to relaunch now or later (for those who care).

@numist
Copy link
Collaborator

numist commented Jul 11, 2013

If it's useful to you, the API can be enabled with:

// This code blocks, so get it to a background queue.
dispatch_async(dispatch_get_global_queue(0, 0), ^{
    // Programmatic enabling of support for assistive devices via https://github.com/mayoff/keyscope
    NSAppleScript *script = [[NSAppleScript alloc] initWithSource:@"tell app \"System Events\"\n\tset UI elements enabled to true\n\tget UI elements enabled\nend"];
    NSDictionary *error;
    NSAppleEventDescriptor *aed = [script executeAndReturnError:&error];

    if (!aed) {
        NSLog(@"Error enabling support for assistive devices: %@", error);
    } else if ([aed descriptorType] != 'true') {
        NSLog(@"Failed to enable support for assistive devices");
    } else {
        NSLog(@"Success!");
    }
});

It's not the same as blessing the process, but it'll unblock things and there's no need to relaunch the application—everything starts working immediately.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants