I have a bunch of macros just like this one for opening files in the Finder with specific applications.
Just recently these have all started to fail with an error message like this one (screenshot below). Actually TWO of these error messages pop up every time.
I've tried going back to the macro and re-selecting the Numbers app (e.g.) again to make sure KM is seeing the app correctly. It is.
I tried this about a month ago and received the same error(s). I forgot about it and didn't chime in to the forum. Maybe @peternlewis can shed some light.
When I try this I get the error you mentioned, but also get a notification that says
"KBM was prevented from modifying apps on your Mac."
Looks like a permission thing.
I added KBM to App Management in the Security panel, but no change. Maybe the engine needs to be added but I don't know how to do that.
set f to POSIX file "/Applications/Numbers.app" -- or whatever the path to the target application is
tell application "Finder" to open (the selection as alias list) using application file f
Try that using the Execute an AppleScript action, ensuring that it includes errors and does not abort the macro (both in the gear menu) and displays the results in a window and see what happens.
Yes, this works to open files with a different default app in BBEdit, but it fails with the -128 error if the default app is BBEdit:
tell application "Finder"
set sel to selection
if sel is not {} then
set filepath to item 1 of sel as text --> The path to the one selected item.
open filepath using application file id "com.barebones.BBEdit"
end if
end tell
It does not appear to be restricted to just BBEdit, but I don't know what the cause is, or why is applies in only certain cases.
When Keyboard Maestro executes the AppleScript for this action, I have seen the system report something like “Keyboard Maestro was prevented from modifying out application files” os some such nonsense, so I wonder if the Finder or the AppleScript system is touching some file and that is resulting in a -128 “user canceled” error.
I'm back on macOS 10.14 (Mojave) and I only recently moved from Keyboard Maestro v10 to v11. The macros I have like Jack_Brannen showed in the original post continued to work after upgrading KM, further suggesting it's a Ventura issue.
I have a Keyboard Maestro macro that feeds a selected file in the Finder to an app (an image to a Retrobatch applet). It broke recently with this -128 error, but I wasn't able to figure out why and fix it (reselecting the applet made no difference). And then it started working again. I dimly remember that there was some sort of extra dialog the first time it worked again, but I was moving fast and not paying attention. Not very useful, but a data point that it happened and stopped happening.
It occurs to me that if this is a security issue, then reinstalling the Keyboard Maestro application might result in the system re-prompting for whatever the hell it is missing.
Quit Keyboard Maestro and Keyboard Maestro Engine
For bonus points, trash the Keyboard Maestro.app, empty the trash, and restart.
Thanks for the suggestion Peter. Performed the reinstall and my system gave the same error. It's just weird because it works fine on my other non-Sonoma systems.