AppleScript and Mojave

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 Project’s 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.

“Since 2018r4 links against the macOS 10.4 SDK you need to update your application otherwise Applescripts will not function”

References:
http://documentation.xojo.com/topics/macos/using_applescripts_in_your_app.html

https://developer.apple.com/documentation/security/nsappleeventsusagedescription

Lifted from a Feedback case :slight_smile:

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.

ScriptText.Append "ignoring application responses" ScriptText.Append "«event MaxSarch»" ScriptText.Append "end ignoring" ScriptText.Append "end tell"

To use AppleScripts under Mojave your app has to ask the OS if the Script is allowed for the SPECIFIC APP with https://www.monkeybreadsoftware.net/applescript-nsapplescriptmbs-shared-method.shtml#1

I don’t know how to do this in Xojo code only.

Did a test for Xojo 2018r4: you need both the function from the MBS plugin AND the plist entry.

Soon, very soon we will have “please confirm that you are allowed to use the mouse”.

[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 you’ll find that the restriction is enforced when your AppleScript targets other applications. Things like tell “Finder” or tell “System Preferences”.

The question comes from that Feedback ;(

@Emile Schwarz: did you read my post?

Please confirm that you are allowed to Use Move the mouse. :wink:

Please confirm that you are allowed to confirm that you want to confirm that you can use the mouse.

Security, please!

Yes, I do.

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).