Applescript Used in My Cocoa MAC App, Stopped Working in Osx 10.14

Reading currently playing track in macOS using ScriptingBridge not working

The key thing is that you must at some point see the dialog that says

MyApp wants access to control “iTunes“. Allowing control will provide access to documents and data in “iTunes“, and to perform actions within that app.

If you have not seen that dialog:

  • In the Entitlements, turn sandboxing off.

  • In the Info.plist, add a Privacy - AppleEvents Sending Usage Description entry with some arbitrary string as its value.

Run the app. If it still doesn't work, then say this in the Terminal:

tccutil reset AppleEvents

and run the app again.

Can you execute an Applescript script from a Swift Application

Tested: one can do something like this (arbitrary script path added):

import Foundation

let task = Process()
task.launchPath = "/usr/bin/osascript"
task.arguments = ["~/Desktop/testscript.scpt"]

task.launch()

Automator throws error on download, but download still completes?

There is a way to have Automator continue on with the workflow without timing out. With AppleScript, If you wrap the download command within a with timeout of 1000 command (1000 is in seconds. Use whatever number you think will work), the script will now wait for up to 1000 seconds for the download command to complete, instead of the default of 120 seconds, before timing out or moving on to its next command.

So instead of adding the Automator Transmit Download action to your Automator Workflow, you can insert a Run AppleScript command to your Workflow


For example let's say you want to download every currently selected file on the remote browser of the current tab in Transmit.app without timimg out, you would insert a Run AppleScript command to your Workflow and insert this following AppleScript code. (obviously editing the properties in the code to suit your needs.)

property downloadLocation : POSIX path of (path to desktop)
property filesToDownload : missing value

tell application "Transmit"
tell its document "Transmit"
set selectedFiles to a reference to selected browser items of ¬
(get remote browser of current tab)
if (count of selectedFiles) > 0 then
set filesToDownload to path of selectedFiles
else
return
end if
repeat with thisFile in filesToDownload
with timeout of 1200 seconds
download remote browser of current tab item at path thisFile to ¬
downloadLocation with resume mode resume
end timeout
end repeat
end tell
end tell

Sample Image

using applescript to add my app to login item but getting a weird entitlement permission issue

Regarding SASyphonInjector.osax error messages, as vadian says this is unrelated to your code.

vadian: “In 10.14 Mojave Apple doesn't allow third-party Scripting Additions anymore.”

This is not entirely correct. Third-party OSAX are still allowed, but they must be codesigned and embedded into the application that uses them (which must be signed with the same identity). However, OSAXen can no longer be installed in global “ScriptingAdditions” folders, nor can they be loaded into one process and then called from another (a massive code injection hole that Apple should’ve closed decades ago). There is a more detailed writeup here, c/o Late Night Software.

Unfortunately, Apple still allow StandardAdditions commands to be called remotely, so malicious code can still [e.g.] display fake “Please enter your Apple password:” dialogs in familiar apps such as iTunes and App Store. But assume OSAXen will eventually go away entirely.

The OSAX in question comes from this project, which used it to inject its own functionality into other apps. You can safely ignore the log error it now generates, though it won’t hurt to clean out your now-defunct “ScriptingAdditions” folders to silence it for good.

Apple Event sends Activate gives an error

You should call:

OSErr err = AECreateDesc( typeApplicationBundleID, arg, strlen( arg ), &addDesc );

without &.



Related Topics



Leave a reply



Submit