Swapping Accounts from Menu Items

Hi guys,

I'm new with KM and would like some help with a macro, please.

I'm trying to create a keyboard shortcut which will allow me to switch between two email accounts within my client.

Manually I change them from a menu dropdown:

Screenshot 2020-06-08 at 05.18.37

Setting something up to change over to one is easy enough using the 'Select or Show Menu Item' action, but how do I set something up which allows me to switch between the two regardless of which one is currently selected using the same hoy key?

I was hoping I was along the right lines using an if condition like below. However, even after playing around with all the settings, I still can't get it to work.

Any help would be awesome :slight_smile:

Most likely since the menu is dynamic, the app is not building the menu until you open it.

When the app is asked for the menus via the accessibility subsystem, the menus are either not there, or not currently correctly built for the context.

Options to force the application into updating its menus include:

  • Switch out and back to the application, and then use the Select Menu Item action.
  • Use the Show Menu variant (leave the item field blank) of the Select Menu Item action to show the menu item first, and then the Select Menu Item.
  • Simulate a click in the menu bar, and then use the Select Menu Item action.
  • Desperate measures, simulate a click in the menu bar, and then use arrows and typeahead (Insert Text by Typing) to select the menu item.

There is an entire topic expanding on these instructions at:

In this case, using the Show Menu option of the Select or Show a Menu Item action would be a likely requirement for building it.

So Show Menu “Accounts” item “”.

Looks like you need to swap the two actions around.

Currently, if tom@pandsmarine.co.uk is marked you then select tom@pandsmarine.co.uk - surely you need to select the other one?

Try swapping the actions!

Hi guys, thanks for the suggestions.

I've updated it to the following:

I'm still having the same problem however. When I'm in the tom@pattle.me inbox the macro works, but when in the tom@pandsmarine.co.uk inbox the macro runs but selects the tom@pandsmarine.co.uk inbox again instead of the tom@pattle.me one.

While typing this, I had the idea of nesting the if's to the following but this doesn't work at all:

Any ideas?

Here are my thoughts @tpa77l3, for what they’re worth.

  1. The fact that when you’re in the pattle account the macro does what it’s supposed to means that the KM action to Select Menu works properly.

  2. The fact is, when you’re in your other account the macro fails.

From this I can say that the KM test of the marked state of the menu is always returning false. This is just confirmed when you nested the If tests: the macro did nothing.

You need to look at an alternative way to phrase the Menu Condition. I’m not at my Mac, so I’m going to be of limited help but can you use a regular expression in the menu condition. For example,

Path that matches .*pandsmarine

(or similar!) would pick out your .co.uk account.

If I get a chance later I’ll look again when I’m at my Mac...

Good luck.

Further to my previous post, I suggest you try something like this:

Let us know how you get on.

Many thanks for the suggestion. I've just tried it but the same thing is happening in that it will switch one way but not the other. I've tried swapping the email's around again to no avail...

Screenshot 2020-06-13 at 06.18.22

Oops - I made a mistake in the regular expression:

Where I wrote *.pandsmarine in the screenshot (which is exactly what you used) it should have been


which is what I wrote in the text of my posting.

Notice it should be .* and NOT *.

Sorry for that.

So, amend the "name matching" field to .*pandsmarine and make sure you switch the order of accounts back in the actions to be executed - first pattle.me and second pandsmarine.co.uk

Tell us how you get on and good luck!

It works! Many thanks.

I'll add 'learn regular expressions' to my someday/maybe list :slight_smile:

Hoorah! I’m so pleased that’s worked although I am left puzzled by the question why your original approach didn’t work.

And even after 4 decades of using regex I still make mistakes! Cheers!