The below code doesn't work since Mojave without Accessibility permission
KeyMap keyStatesBig;
GetKeys(keyStatesBig);
But is there a key to put in info.plist to ask users permission on app launch?
If you later decide to give a denied app access to your Mac, choose Apple menu > System Preferences, click Security & Privacy , click Privacy, click Accessibility, then select the app's checkbox.
To change application permissions on a mac, click the Apple icon → Click "System Preferences" → Click "Security & Privacy" → Click "Privacy" → Click on a service → Click the check box to add or remove an app's permission to the selected service.
It's not possible with the info.plist
.
You can ask the user yourself, on startup. Use AXIsProcessTrusted to determine whether accessibility is enabled or not.
If it's not enabled, you can show a dialog asking the user to switch it on.
You can open the relevant preferences for the user also:
NSString* prefPage = @"x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility";
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:prefPage]];
See how Dropbox does it (this is custom UI):
(The Turn on Accessibility
button simply opens the System Preferences to the correct place, as mentioned above)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With