Clicking with Modifier isn't working as I expect - opening links in background

Likely pilot error, but, my email client (MailMate) displays certain things as clickable. If I manually hold down the Command key, and click, the link is opened in Safari in the background, keeping MailMate the front window. In this specific case, the thing I click is a standardised URL to an internal server within my LAN.

If I click on the link without command key, then, as expected, focus changes to Safari.

In Keyboard Maestro, I've created a Macro which finds this specific type of link in certain emails I have by doing an image search on the page, and then "clicks" in that location.

This works exceedingly well, however, it even though I've ticked the With Modifier (Command), it will always click as if the Command key is not being held down, and shift the focus to Safari.

Is there a way to use KM to find the "clickable thing" in my view, but, do what I want whereby the clicked upon thing is opened in the background?

I realise I can fake the outcome by having my macro quickly shift focus back to MailMate, but I'd rather not have to do that.

Am I doing something wrong, or is this just not doable the way I want it done?

Thanks!

To start with the basics... I find that a macro containing this action works as expected with MailMate, for a link pointing to a page on the Web:

Are you implying that your macro fails to command-click with the expected result only for that URL? If so, what is the URL? We would need to consider how it differs from the URL for a page on the Web. My test macro containing just the action above works with local URLs for me, but I don't know what format your URL has.

I do wonder if clicking on an image is the best way. Remember that you can get the source of an email (⌥⌘-O), so you could then copy that raw source text (⌘-A, ⌘-C) and extract the URLs.

If you need more help, please include a copy of your macro in your reply (or a stripped-down version of it that illustrates the problem.

You know how, if you use the word “attached” in MailMate, it points out if you haven't included an attachment? Well... :wink:

Thanks kevinb, some good questions, and I likely should have included a bit more data when posting.

Here's the salient bit of the macro:

As you can see, all I'm trying to do is locate the URL in my plain-text email within MailMate and "command-click" on it so that it opens it in the background without changing focus from MailMate.

If I manually command click the link, it works fine.

The Macro has no problem finding the link, and clicks on it, but, does not behave the same as a command-click - the macro clicks correctly, but, Safari is then brought to focus.

I manually work around this by having a second action in the Macro which simply Activates MailMate after about 0.5 seconds after the click step above.

This is the only Macro I have which attempts to do this, and I haven't tried to get this to work with other URLs that may be visible in my email.

The URL is (and I'm masking out some bits):
"https://myserver.example.com:9275/path/update.html?status=ack&id=7772"

For context, a piece of automation is emailing me an update to a process. Within that email is a link that I can click which will go back to the server and acknowledge the update.

So, for the example URL above, clicking on that link will take me to my server, with the web-app running on a specific port, and ACK the event with ID number 7772. Obviously, this assumes I've already authenticated to the server initially.

The macro is looking for the "image" of the majority of the URL on screen, which in this example is everything before the id= in the URL. KM has no problem at all finding this reliably.

My goal is to bind a key on my StreamDeck to find this type of URL pattern in the plain text email (no HTML at all) and "ack" an event without leaving MailMate.

As I may receive quite a few of these, I want to do this as swiftly and as efficiently as possible, so going through the extra steps of trying to access the raw source of the message and copying/parsing the content would be far slower - I did try that approach initially, but email encoding and wrapping caused some headaches.

My workaround works (re-activating MailMate), but I was hoping I could skip that step.

Hello again and thanks for clarifying. It seems—from what you write and from my testing—that the problem is purely to do with command-clicking on an image. I can confirm that the simulated command-click does not open the Web page in the background (when using Safari or another browser that is capable of doing so).

I do not know why the simulated ⌘-click is not working as expected, but I have a solution. I found a post by @noisneil which solved a different but somewhat similar problem, and I tweaked his macro to come up with the following one. Please confirm that it works for you too; else we can look at the issue again.


Mailmate command-click.kmmacros (23.1 KB)

1 Like

Just be sure to set any actions in between the scripts not to abort on failure, as you don't want your modifier stuck in the down position.

1 Like

Thanks for the tip, @noisneil.

@dotsplatslash You probably knew already, but just in case: you can disable "failure aborts macro” under the cogwheel for that move or click mouse action.

image

Edit: I have updated the uploaded macro accordingly.