Jump to content

AppleScript apps lose accessibility permissions when run by Alfred

Recommended Posts

I have an AppleScript app (~/Library/Scripts/ChooseLanguage.app) that I want to trigger with Alfred.  The app opens a dialog for me to select a language, and then enables my Typinator rule sets for the language I chose, and disables rule sets for other languages.  Next it changes my keyboard layout ("input source") to the chosen language.  This second step requires that I give it permission in System Preferences → Security & Privacy → Privacy → Accessibility to enable it to run.


If I trigger the app manually, it has no problem using the permission I've granted it.  But if I trigger it from Alfred, I get a message that it does not have adequate permissions:



ChooseLanguage is not allowed assistive access.

System Events got an error: ChooseLanguage is not allowed assistive access. (-1719)



It very clearly is allowed assistive access, as is Alfred itself.  This therefore appears to be a bug with how Alfred triggers it.  The problem occurs whether I use a hotkey or keywords to trigger the AppleScript.

Link to comment

The problem may be that Alfred creates its own copy of the AppleScript (does it???) and uses that instead.  So even though the AppleScript app had the permissions it needed, Alfred was using an older copy that didn't.  


I deleted the AppleScript and created a new one with a different name and made sure it had all the permissions before telling Alfred about it.  This time things worked.  So the bug is possibly related to (1) using a copy, and (2) not getting a fresh copy when important things like that change.

Link to comment

@iconoclast Alfred doesn't do anything odd when running things, and doesn't take a copy of external scripts as you theorise. I suspect that this is more of a consequence of how Mojave organises and caches permissions. For example. after Alfred requests the process of allowing permissions himself, he has to restart himself manually for those permissions to take effect.


I'm not entirely sure there is anything I can do to fix this from Alfred's side, but I suspect that as Apple refines the (relatively new) permission architecture, things like this should become more streamlined.




Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...