The Scrivener app bundle contains an .sdef file in Resources.
Scrivener does NOT respond to the standard Script Editor’s request for dictionaries nor does the info.plist designate Scrivener as ‘Scriptable’ BUT the .sdef file can be opened by Script Editor!
Further Scrivener does in fact respond to AppleScript:
e.g. Tell application “Scrivener” to version’
However there is an error in the .sdef
The .sdef states that a document has a property of ‘file’ (of type ‘file’)
But in actual usage a document does not have a property of ‘file’ - it does have a property of ‘path’ (of type ‘string’)
It would be my hope that the .sdef file be updated such that a document is said to have a string property of ‘path’.
Of course also correctly providing the ‘file’ property could be useful but in this case please leave the ‘path’ property!
This means of remedying the .sdef would not break any existing scripts.
Upon further investigation I’ve discovered a show stopping issue for my use of AppleScript and Scrivener.
I provide my app the the Mac App Store. As such I must provide an entitlement for each application that I interact with.
With Mojave & Catalina I must also provide a Privacy permission which the user must grant.
When I attempt to use the provided function ‘AEDeterminePermissionToAutomateTarget’ in order to inquire as to the Privacy status, this function throws an error : “…could not find application for address descriptor.”
This error makes it impossible to use Scrivener as a target application for applications which abide by the rules imposed by the Mac App Store.
NOTE: the ScriptEditor will happily run the AppleScript I need but Scrivener does not provide the necessary mechanisms to be target applications when this occurs programmatically rather than directly by a user.
Please consider remedying this issue! So close and yet…