Tahoe: command fails in applet, not in script

I’ve long had a Finder toolbar applet to open a selected file in not-the-default application.
Now I’m moving my stuff to a new Mac with Tahoe, and it won’t work, that is, it runs, but the selected file is not opened. The command to do that is the last line of the script:

tell application id "MACS" to open file HFSpathToFile using application file id bundleid

To have it run I had to:

  • recompile into a fresh applet (this added Assets.car)
  • allow it to control Finder when asked.

I stuck in several display dialogs to see intermediate results, and lo & behold, when I added a display dialog AFTER the last line it worked!
So now I have this:

	tell application id "MACS" to open file HFSpathToFile using application file id bundleid
	display dialog "" giving up after 1

It must be a display dialog; inserting return has no effect.
It works as intended, without the silly addition, when run from the Editor.
It also runs as script, minus the idiotic dialog, from the Script Menu.

Any ideas as to the cause and/or solution?

Since the first part of the script is missing, I cannot give any certain answer.

But I noticed two things.

First, I think the class of HFSpathToFile is probably a list.
log class of HFSpathToFile as text
Sometimes opening a list with
open file ... using application file id ...
can cause an error.
If HFSpathToFile is a list,
you may need to open each item one by one inside a loop.

Another thing is TCC.

With using application file id bundleid, macOS may require permission in
System Settings > Privacy & Security > Automation.
Since an applet is a script application, permission may be needed for the bundle ID of the application being called.

Because of that, if you are using an applet, I think
tell application id bundleid to open file aliasFilePath

may cause fewer problems than opening the file from Finder with open.
I’m not sure if this is helpful, but you may also want to look at this example.

1 Like

Almost every Finder toolbar applet on my Tahoe computer requires Full Disk Access permission, and you may want to check this. As IceFole notes, other permissions may be required, depending on what the AppleScript does.

First thing the script does is test the Finder selection.
Omly a single document is accepted.
No problem there.

I had added it to Automation, but not Full Disk Access.
Made no difference.

IceFole’s rephrasing of the command finally did it - after I had logged out & back in…

Thank you both for your help.