I do not have a build license for Xojo 2018r4, but I am curious to know how to use AppleScript (on Mojave).
Is the info.plist below valid ?
[code]<?xml version="1.0" encoding="UTF-8"?>
NSAppleEventsUsageDescription
MyApp uses Applescript for its own purposes.
[/code]
The data above was saved to a text file (named info.plist) and dragged into the Xojo Projects Navigation pane. The project runs in the IDE, but this is the only thing I can say about that.
A test report is welcome (Yes it works / No [change this or that ]) TIA.
You can use AppleScript in the very same way as before.
The AppleScript Example(Add two Integer value) in the Documentation runs just fine on macOS 10.14. No warnings, no user confirmation - it just works as expected, even in a Xojo 2018r4 built application running on macOS 10.14.
With Script Editor: Compile and Save as Script with Filename: Add.scpt
on run {value1, value2}
return value1 + value2
end run
Drag the script in your Xojo Project. And in Xojo Code:
Dim sum As String = Add(5, 10)
The Restriction is: usage of AppleEvents (in an AppleScript)
My guess is that AppleEvents are things like: tell application "iTunes" or tell application "Finder" in an AppleScript.
But I’m not quite sure if that’s correct (or if that is all that is restricted)… I’d appreciate an answer of someone how can clarify what AppleEvents are. Which “Actions”, what “Code” in an AppleScript is considered an AppleEvent?
Because we only need this additional Info.plist entry for using AppleEvents - not for a simple AppleScript.
But that’s not quite correct. A simple AppleScript will function just fine. See the example above.
It would be good to clarify what is common and yet different in AppleScript and NSAppleEventsUsageDescription.
AppleScript under Mojave work (more or less fine) without the NAAppleEvents… definition under Xojo 2018r3.
An AppleEvent is a single atom of an AppleScript. For instance, I use a simple AppleEvent to start something in the main app from the helper app. The part with event below is the AppleEvent.
[quote=418668:@Jürg Otter]But that’s not quite correct. A simple AppleScript will function just fine. See the example above.
It would be good to clarify what is common and yet different in AppleScript and NSAppleEventsUsageDescription.[/quote]
I think youll find that the restriction is enforced when your AppleScript targets other applications. Things like tell Finder or tell System Preferences.
macOS 10.14 no longer simply allows every app to use AppleScript to Automate other applications.
Just in case anyone is interested in an example that shows:
how to use AppleScript Automation
determine if the app has permission to automate another running application
how to open System Preferences at Privacy - Automation
It’s a couple of additional steps and Declares - but it can all be done with Xojo (no Plugins required).