How to Open the URL of Local File in Chrome?

I have a macro to open the selected urls. But when the url is a path of a local file, e.g. file:///Users/xxx/Desktop/xxx.pdf, the "open url" action somehow fails. But a simple copy-paste-return does work in chrome. So what's the solution in this case?


Why don't you use this action instead?

Thanks for your reply. This doesn't work either. I think there might be some problems with chrome accessing local files. Though entering the address of local file in the address bar does work.

Chrome doesn't seem to open on my Mac either. Maybe a pdf reader extension is needed?
It works with Firefox and Safari.

But I initially meant to suggest you use other PDF reader apps, such as Preview or other third party apps. I never use web browser for reading local pdf files.

Confirmed. This FAILS, does NOT open the file in Chrome:


This works:

@peternlewis, this suggests to me that there may be a bug in the KM Open URL Action.

(Sorry, I had an idea but then I realized I'd missed something that made my idea not likely to be helpful.)

It's unlikely the Open URL action has any bugs in it, since the Open URL action is trivial, it just hands the URL to the system to open, there just isn't a lot of scope for bugs to hide. At its heart, it is just a single line of code.

		good = [[NSWorkspace sharedWorkspace] openURLs:@[url] withAppBundleIdentifier:bundleid options:options additionalEventParamDescriptor:nil launchIdentifiers:nullptr];

In any event, I tried opening a pdf with a space in it in Chrome, then copying the URL from the address bar and opening it with the Keyboard Maestro Open URL action, and it opened in Chrome fine for me.

So I would guess there is something else going on. Maybe there is an issue with which Chrome application is selected in the action, or an issue with the URL or an issue with permissions.

Note that the New Google Window/Tab use a completely different mechanism. The latter uses AppleScript to talk directly to Chrome. The former uses NSWorkspace.

Well, I was originally going to say, I wonder if this is a problem where Keyboard Maestro does not have Full Disk Access.

Could that be the issue?

FWIW, I always make sure to add Keyboard Maestro and Keyboard Maestro Engine to Full Disk Access, as shown here:

If either/both are not there, click the + in the red box to add them. You can find the at

/Applications/Keyboard Maestro