How to use `click` in a shortcut? (Run a service when clicking a link)

automatorclickservicesshortcutshortcut-menu

Is it possible to run an Automator service with an alternate click, e.g. ⌘ + ⇧ + Click? This kind of combination is built into browsers with ⌘ + Click typically opening a link in a new tab.

I have a service for handling links. Right now I can right click the link, pick services from the context menu, and then select my service. I'd rather not navigate the menu. Is there a way I can harness Click when making a shortcut?

A half-option is to right click the link, click elsewhere to close the dialog, and then press the keyboard shortcut, but this is cumbersome. (I'd be happy enough if I had to right click and then do a shortcut, but this seems to not work without clicking away.)

I've internet sleuthed with enough search strategies that I think this may not be possible but am hoping I'm wrong and simply a careless querier!

Best Answer

BetterTouchTool

You can use better touch tool to remap your clicks on your trackpad or mouse. Here is a screenshot of the rule I created. It copies the url from the hyperlink and sends this to a shell script, where you can handle it as you wish.

BetterTouchTools Mapping Rules

The last line actions, "Execute Shell Script" has this configuration:

Script Action Configuration

This just runs an executable script and pastes in the url as its argument. If you don't want to use a bash/zsh script you can use applescript or javascript or python or perl or whatever you are comfortable with by changing the launch path.