Get/Set Accessibility Permissions?

Hey Folks,

I’ve had terrible problems with FastScripts 2.7.x and the system Accessibility prefs.

FastScripts gets stuck and cannot be deleted from the Accessibility preferences even after a reboot (on macOS 10.12.6).

I finally managed to get FastScripts 2.7.3 working after 2 reboots and a serious amount of fiddling – but I still wasn’t able to delete it…

No other app in the Accessibility prefs has this problem.

Has anyone seen anything similar to this?


Because of the above issues I went looking for a means to directly delete the listing in the Accessibility database and unfortunately didn’t find much.

Does anyone know how to get/set Accessibility Permissions using AppleScriptObjC or the shell that works on a system with SIP active?

Apparently the Accessibility database is read-only as of Sierra.

-Chris

Chris: I’m having the same problem with a couple applescripts. Apple has locked out all access to the sqlite database at /library/application support/apple.com.TCC and I couldn’t access it with DB Browser.

Chris, you probably have seen/tried this, but just in case, this was in the Release Notes I saw today with the FS 2.7.3 update:

Important Note: After updating from FastScripts 2.6.13 to 2.7 or later, you may experience trouble running scripts that rely upon accessibility and GUI scripting support.

To work around this problem, go to System Preferences -> Security & Privacy -> Privacy -> Accessibility, and uncheck any existing copies of FastScripts listed. Then restart your Mac before adding back FastScripts 2.7.2. This should restore functionality as it was with 2.6.13.

Hey JM,

Yep. It didn’t work for me.

I had to add FastScripts back to the Accessibility list and then start, quit, restart the app – before things stuck.

If you’ve installed FastScripts 2.7.3 then please quit and restart it.

Look at the prefs:

~/Library/Preferences/com.red-sweater.FastScripts.plist

And tell me whether the prefs were recreated and modified when you quit/restarted FastScripts.

-Chris

Hey Folks,

I figured I’d have to scrag my Accessibility database, so I wanted to save the list of registered apps.

Of course Apple has made this difficult to do, but at least it’s possible with UI-Scripting.

I reckon you can also read the Accessibility database, if you know enough SQL.

-Chris

----------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2018/09/01 15:06
# dMod: 2018/09/01 15:59
# Appl: System Events, System Preferences
# Task: List Applications with Accessibility Permissions.
# Libs: None
# Osax: None
# Reqs: BBEdit
# Tags: @Applescript, @Script, @System_Events, @System_Preferences, @List, @Applications, @Apps, @Accessibility, @Permissions
----------------------------------------------------------------

tell application "System Preferences"
   activate
   
   set accessibilityPane to pane id "com.apple.preference.security"
   
   if current pane is not accessibilityPane then
      
      set current pane to accessibilityPane
      
      repeat while current pane is not accessibilityPane
         delay 0.25
      end repeat
      
      delay 0.25
      
   end if
   
   tell accessibilityPane to reveal anchor "Privacy_Accessibility"
   
end tell

tell application "System Events"
   tell application process "System Preferences"
      tell window "Security & Privacy"
         tell tab group 1
            tell group 1
               tell group 1
                  
                  repeat until ((exists of button 1) is true) and button 1's help is "Add an application"
                     delay 0.1
                  end repeat
                  
               end tell
               
               tell scroll area 1
                  tell table 1
                     tell rows
                        set appsWithAccessibilityPermissions to name of UI elements
                     end tell
                  end tell
               end tell
               
            end tell
         end tell
      end tell
   end tell
end tell


set AppleScript's text item delimiters to linefeed
set appsWithAccessibilityPermissions to appsWithAccessibilityPermissions as text

bbeditNewDoc(appsWithAccessibilityPermissions, true)

----------------------------------------------------------------
--» HANDLERS
----------------------------------------------------------------
on bbeditNewDoc(_text, _activate)
   tell application "BBEdit"
      set newDoc to make new document with properties {text:_text, bounds:{0, 44, 1920, 1200}}
      tell newDoc
         select insertion point before its text
      end tell
      if _activate = true or _activate = 1 or _activate = "activate" then activate
   end tell
end bbeditNewDoc
----------------------------------------------------------------

Yes, it was recreated.

1 Like

Chris, do you have a simple, non-invasive UI script we can use to test this with?

Hey JM,

The simplest script I know had problems, because I used it to test with is this:

tell application "System Events"
   tell application process "Keyboard Maestro"
      tell window "Keyboard Maestro Editor"
         tell scroll area 2 of splitter group 1 of group 1
            set focused to true
         end tell
      end tell
   end tell
end tell

It changes focus in the Keyboard Maestro editor to the macro list.

I suspect any script trying to access UI elements via System Events will throw an error when FastScripts is not registered, but I have not tested a super-simple case.

-Chris

Hey Folks,

Oh, one more thing about this FastScripts trouble.

Switching to v2.7.3 has lost me quite a few keyboard shortcuts.

I’m just guessing but I’d say maybe 5-10%.

I’m not happy and am formulating a bug-report for Daniel right now.

-Chris

Chris, I got it to work!

First, it works perfectly from SD.
Second, I got this using FS:
image

Then I did this:

  1. SP > Security > Accessibility > Uncheck FS
  2. Quit FS
  3. SP > Security > Accessibility > CHECK FS
  4. Launch FS
  5. Test FS (using FS menu)

Success❗

HTH!

1 Like