Here's my scenario: I am trying to emulate the Superhuman app and save $30 a month by using Mac Mail instead. In Superhuman, when you are reading an email or simply have it highlighted you can click the "E" key and it will move it into a "Done" folder basically. This was fairly straight forward and I got that working, but the issue now is that I have different email accounts (Gmail, Work, etc.) so the "Done" folder is different for each account. I now would need to wrap this in an if/then/else statement so that I can send the email to the correct "Done" folder.
Here's how I "think" I can do this. (If you have a better way, please let me know) In Mail, when you are on a particular email account the menu changes dynamically under the "Window" menu and shows the email account you are in. I'd like for Keyboard Maestro to look under the "Window" menu for the word "Gmail" and ensure that it is checked. Once it knows that I'm on my Gmail account, then I can move the highlighted email to the correct "Done" folder.
So I guess my actual question is "How can I find dynamically changing text within a sub menu item?"
If you look at my screenshot you will see that I am trying to look under the "Window" menu for the word "Gmail" and ensuring it's checked using "Is enabled". (I don't know if I can even do Regex for a submenu item)
I'm not entirely sure what you want (sorry), but if you want to know which account you are logged in to, try using this action (when Mail is the active app):
I have updated the original question to hopefully make my question make more sense.
While I wish your solution worked for my situation, I don't believe it will because it's always going to find "Gmail" in a menu item somewhere, and I'm trying to make different decisions based on the highlighted email I have...which may not be in my Gmail account.
If you can show specifically why that will happen, we can probably amend my IF statement to make it work. But I can't update my code to work without more detail.
A secondary issue is that, for some apps, the menus are not actually updated or populated until you actually, physically display them. You probably think that they are updated prior to the user actually accessing them, but that's not always the case for some apps.
You can do some experimenting to see if "Mail" is one of those apps that doesn't update the menus until they are actually displayed.
I can find the word "Gmail" in 4 submenu items that is always going to be there simply because I set up my Gmail account to use the Mail app...so if I'm simply looking for the word "Gmail" it will always result in TRUE.
Note: I know enough to think I know what I'm talking about...but I could be completely wrong...and probably am. Thanks
Here's how I would do it: Use the Front Window token in order to then use regex to find the inbox name in the Mail window name and set it to a local variable. Then use the local variable to select the appropriate menu item.
Although in the middle of all that, I would also be posting here in the forum to ask how to write the regex because that I don't know. But I do something similar in another macro.
Sorry. That's exactly what I thought you wanted, for when you were logged into Gmail. I was assuming that you meant that when you switched to different accounts, the word "Gmail" would change to your other accounts. Perhaps I assumed wrong. I will let other people answer you now, as many people on this forum are smarter than me.
We are all doing our best. My success rate at solving problems may only be about 50%, but that doesn't stop me from trying.
This is a great idea and I tested/tried it and the issue I'm running into with this solution is that you can always click the "All Inboxes" so the "WindowName" won't show which email account you are in. I appreciate the idea. One major thing this idea showed me is that my original idea won't work either for the same reason. THANK YOU
Macros are always disabled when imported into the Keyboard Maestro Editor.
The user must ensure the macro is enabled.
The user must also ensure the macro's parent macro-group is enabled.
System Information
macOS 13.6.1
Keyboard Maestro v11.0.3
The key is to ensure that Mail is frontmost and then use regular expressions to identify which account is in use. The coloured actions should be replaced to deal with the different accounts.
Since you have more than 2 accounts, you'll need to use further nested "if-Then-Else" actions to cope with that. Normally I'd use Switch action but it doesn't support the menu condition.
I tested/tried this solution as well and it has the same issue as the other options (even my initial solution)...when you select the "All Inboxes" it loses context as to which account the selected email is under.
I think the solution would have to be based on capturing data based on a selected email instead of trying to use the menu data as the determining factor for which path to go down.
Maybe this isn't something that can be done, it's not that big of a deal, but if I could make it work, I'd like to. Thanks for you solution.
Such a condition would never occur to me because if I had more than one I would never be working in All Inboxes. However, to solve for that I would try using Mail tokens and Switch Case. Something like:
If you do find you have problems with this approach you can use AppleScript instead. A quick hack, which could be optimised and also changed to cope with multiple items:
tell application "Mail"
move item 1 of (get selection) to mailbox "Done" of account of mailbox of item 1 of (get selection)
end tell
Easy enough to pop into an "Execute an AppleScript" action in a macro you can hotkey trigger.