问题
I have an app that uses a (perfectly user-benevolent) system-wide keyboard hook for accessibility purposes.
When the app starts up, I check if the "Enable Access for Assistive Devices" setting is checked, as asked by someone else here: Programmatically determine if "enable access for assistive devices" is checked in Cocoa app
My problem is that, even after Enabling Access via the checkbox, the app continues to run without those privileges. How do I give the (currently running) app the privileges and get the keyboard hook working? Do I need to restart the app?
回答1:
Looking through the link you posted,
I asked the Accessibility engineer again, and apparently you have to re-exec or re-launch the now-trusted application for the new state to take effect.
I would present the user with a notification or message that the application has to restart to enable assistive privileges, then restart it.
来源:https://stackoverflow.com/questions/9132845/how-do-i-give-my-app-assistive-access-privileges-once-enable-access-for-assis