Applescript in 10.14 - Asking for a simple explanation

I used to be able to fire up a AppleScript I made to display the GetInfo dialog for a file. It looked like this:

on run {PathLine, parameters}
set PathLine to alias PathLine
tell application “Finder”
open PathLine’s information window
activate
end tell
end run

It doesn’t work on 10.14 and up with the latest Xojo 2019.03. I read about having to include a key NSAppleEventsUsageDescription in the Info.plist, so I learned how to put a Info.plist in my Project so it would add to the generated app plist. But it still doesn’t work.

(I can make the NSAppleEventsUsageDescription key, but what’s the value?)

I did a search on Google and on this forum and there’s lots of complicated discussions abut AppleEvents and etc. but nothing on just running a simple AppleScript in 10.14 and up where it actually works. I want it to work in debug and in release as well, of course.

Help?

Don’t try to script the Finder.

1 Like

As long as the App is not targeting the App Store and System Integrity Protection is not needed, it’s ok. That’s why Apple made it possible i’d say.

What do you get with this?

on run {PathLine, parameters}
Try
set PathLine to alias PathLine
tell application “Finder”
open PathLine’s information window
activate
end tell
on error etxt
display dialog etxt
end try
end run

Yes, “'s” is a valid AppleScript syntax. I’ve even tried with your example, changing back to the “'s” version and it still works (note that “item PathLine” in your example is redundant, as PathLine is already an alias (a “subclass” of item)).

I’m now checking why your example works and not Garth’s one…

Garth, are you sure the path you’re passing to the script is still a “HFS” path (i.e. separated by ”:”)?
The “alias” resolving system is still expecting them, not Posix paths (still true on my Mojave system, at least). This may be the problem.

For what it worths, when I copy the script in your original post, paste it in Script Editor, remove the Run handler, replace “PathLine” by an existing HFS path on my system and replace mangled characters (" and ’ looks mangled from this forum (or from your example?)), then it works here.

usually you put in a sentence saying what you want to use apple script for
https://developer.apple.com/documentation/bundleresources/information_property_list/nsappleeventsusagedescription

I also usually avoid scripts and do everything using AppleEvents.

But, here, it’s is an edge case. Actually, I never could make this working (showing the information window of a file, or similar commands).
Basically, it’s a matter of having 2 AppleEventObjectDescriptors: one being the “information window” class and the other being the “alias” (file or folder). You’d have to “get of ”, but I’m clueless as to how to convert a folderitem to an AppleEventObjectDescriptor.

In Xojo, the only way I’m aware of to pass a folderitem to an AppleEvent is using the FolderItemParam, but the folderitem can’t be a separated parameter: it must be an AppleEventObjectDescriptor for the information window of the folderitem.

Would appreciate a solution for this since years ago… It’s also true the Xojo implementation of AppleEvents is lacking things.

Yes, that’s good, no problem. We now have to verify why it doesn’t work with the original code but it works with yours.

Better than waiting for an error like in my example, granted.