Possible to test whether an app is listed in the Accessibility pane of Privacy & Security?

As the header says, is there a way to test whether my application is listed in the Accessibility pane so that I can prompt the user on how to fix it? I need to ask, because the application that needs to be listed is buried deep inside my script bundle, and the only way to add it to the pane (at least the only way I can find) is to drag it from a Finder window into the pane.

Thanks for any help with this.

Not via AppleScript (including ASObjC).

Thank you - I should have done some more research, like this:

As this says, there’s no way to do this in an app that you ask users to download. Thanks again for confirming this.

It seems to me that your app, after it is downloaded and run, lcould drop an AppleScript script in an OSX folder somewheres, and then invoke Script Editor to compile and run it. An AppleScript run by Script Editor, according to the link, is allowed to check which applications are listed in the security pane. The script can then dump the list to a text or log file, which can be opened by your app.

Thank you for this. It would work, but only if the user has already granted accessibility permission to the Script Editor, and there’s no way to count on that. But I’m still hoping for a solution!

set theBundle to (path to library folder from system domain as text) & "PreferencePanes:Security.prefPane:"
set privacy_loc to localized string "CFBundleName" from table "InfoPlist" in bundle file theBundle --> "Sécurité et confidentialité"

tell application "System Preferences" to activate
delay 1
tell application id "com.apple.systemevents" to tell process "System Preferences"
	set frontmost to true
	tell menu bar 1
		-- get name of menu bar items --> {"Apple", "Préférences Système", "Édition", "Présentation", "Fenêtre", "Aide"}
		-- get name of menu bar item 4 --> "Présentation"
		tell menu bar item 4 to tell menu 1
			-- get name of menu items --> {"Précédent", "Suivant", "Afficher toutes les préférences", "Personnaliser…", missing value, "Classer par catégorie", "Classer par ordre alphabétique", "Rechercher", missing value, "Accessibilité", "App Store", "Bluetooth", "Bureau et économiseur d’écran", "CD et DVD", "Clavier", "Comptes Internet", "Contrôle parental", "Date et heure", "Démarrage", "Dock", "Économiseur d’énergie", "Extensions", "Flash Player", "Général", "iCloud", "Imprimantes et scanners", "Java", "Langue et région", "Mission Control", "Moniteurs", "Notifications", "Partage", "Réseau", "Sécurité et confidentialité", "Siri", "Son", "Souris", "Spotlight", "Time Machine", "Trackpad", "Utilisateurs et groupes", "Activer le mode plein écran"}
			
			click menu item privacy_loc
		end tell
	end tell
	repeat 20 times
		if exists window privacy_loc then exit repeat
		delay 0.1
	end repeat
	tell window privacy_loc
		get class of UI elements --> {button, button, button, button, tab, button, button, button, toolbar}
		tell tab group 1
			--get class of UI elements --> {radio button, radio button, radio button, radio button, scroll area, group}
			tell group 1
				get class of UI elements --> {static text, scroll area, image, group} # Don't disable it
				tell scroll area 1
					-- get class of UI elements --> {table, scroll bar}
					tell table 1
						-- get class of UI elements --> {row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, column}
						set appsEnabled to {}
						repeat with i from 1 to count rows
							tell row i
								-- get class of UI elements --> {UI element}
								tell UI element 1
									-- get class of UI elements --> {image, static text, checkbox, image, static text}
									
									set end of appsEnabled to (name of static text 1)
								end tell
							end tell
						end repeat
					end tell
				end tell
			end tell
		end tell
	end tell
end tell

return appsEnabled

Yvan, This is brilliant. If used in a compiled script, the user would need to grant access to it in order to test whether the app itself is listed, so I’ll have to think about this more. Meanwhile, this is really excellent. Thank you.

I know this is an old message, but there’s a problem with it that @Piyomaru pointed out in his blog the other day: the execute command has been removed from Script Editor since macOS 10.14.