How do I give my app "assistive access privileges" once "Enable Access for Assistive Devices" has been checked?
Asked Answered
C

1

2

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?

Commissionaire answered 3/2, 2012 at 17:29 Comment(1)
Your app privs are probably set on startup, so yes, you probably have to restart your app.Ics
B
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.

Birdiebirdlike answered 13/2, 2012 at 7:13 Comment(1)
If this is a big problem, you could run the keyboard hook in a small, secondary executable (which could also live in the same bundle) which could be cycled if necessary by the primary app, and relay key-press notifications back to the main app via some other means. But if you can just require a restart of the app, that'll be the simplest.Tailband

© 2022 - 2024 — McMap. All rights reserved.