dimanche 1 mars 2015

Assistive Access when script is launched by agent


Problem


Applescript run by osascript is not allowed Assistive Access when launched by agent (~/Library/LaunchAgents). Although it works when run from Applescript editor or commandline directly (using osascript).


Situation


The applescript performs several GUI tasks for batch printing and is run twice daily. Therefore it needs permission to access Assistive Devices and is launched by an agent.


The script runs as expected when launched from:



  • Applescript Editor

  • osascript commandline (non-sudo)


When launched by Agent it returns:



/location/of/my.scpt: execution error: System Events got an error: osascript does not have access to assistive devices. (-25211)


(Message translated from Dutch by me.)


This led me to believe the issue is with osascript, but like I stated above, it works fine when entered directly from command-line using: osascript /location/of/my.scpt.


Also, based on these two posts I edited the /Library/Application\ Support/com.apple.TCC/TCC.db SQLite database and when I check the 'access' table it shows:



$ sudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "SELECT * FROM access"
Password:
kTCCServiceAccessibility|com.logitech.gaming|0|1|0|??

kTCCServiceAccessibility|com.valvesoftware.steam|0|1|0|??

kTCCServiceAccessibility|com.blizzard.starcraft2|0|0|1|
kTCCServiceAccessibility|com.apple.AccessibilityInspector|0|1|0|??

kTCCServiceAccessibility|com.apple.ScriptEditor2|0|1|0|??

kTCCServiceAccessibility|com.apple.Terminal|0|1|0|??

kTCCServiceAccessibility|/usr/bin/osascript|1|1|1|
kTCCServiceAccessibility|com.my.label|0|1|1|
kTCCServiceAccessibility|/osascript|1|0|1|


As you can see osascript is allowed access and I also added my agent's .plist for good measure.


Possible Cause?


The only thing I can think of is that, for some reason, the script is run by a 'different user' when launched by an Agent and therefore has different assistive devices allowed? Seems unlikely, however, as the TCC.db does not seem to be user-specific and the agent is located in ~/Library/LaunchAgents.


Help, anyone?





Aucun commentaire:

Enregistrer un commentaire