AppleMail - navigate through Inbox mailboxes with shortcuts [SOLVED]

I have multiple mailboxes and I like to keep them empty, meaning I processed all the emails I received, but I always have to click each, one at a time. I would like to have a shortcut to go down/up, similar to how we can navigate emails inside a mailbox by using the up/down arrows.

image

Is this possible with KM? Maybe I could use Option+up/down arrows or something like that.

⌃⌘[ and ⌃⌘] move from mailbox to mailbox, as seen in the Mailbox menu:

image

-rob.

2 Likes

You kinda gave me hope when I saw the email notification... unfortunately, that is probably something they added after Catalina, which is the OS I have installed.
Do you think this is something KM would be able to emulate?

Using UI Browser, I get this when I hover over the first mailbox
image

And for the other mailboxes below the number changes for the "outline row". The first is "3" and the last one is "11"

Probably doable in AppleScript, but I'm not the right one to ask that question. The question is whether Mail provides any way for AppleScript to know what the active mailbox is, so it can start scrolling from there. And if it's possible to write it generally to work for any number of mailboxes, so you can add and remove them without breaking the script.

-rob.

1 Like

I tried this for a particular mailbox, as a test, but it's not working:

tell application "System Events"
	tell process "Mail"
		
		click static text 1 of UI element 1 of row 5 of outline 1 of scroll area 1 of splitter group 1 of window 1
		
	end tell
end tell

then started testing new versions by removing the first element (static text 1, then UI element 1), but none of those worked.

Even if I had to select the first one manually, that would be ok. All I really need is a way to go to the next one. I could work with a variable that changes up or down depending on the shortcut I use to make it "scrollable" and knowing how many mailboxes I have, I could define a "floor" and a "ceiling". Even if I change the number of mailboxes in the future, that would be easy to fix.

But it seems that it's not even clicking the "static" mailbox I defined in the script...

You could probably do it with two triggers, click at location, and a bunch of weird math logic to find next and previous rows (they look to be about 30 pixels apart in my Mail). But that's a complete kludge, and hopefully an AppleScript expert will chime in.

-rob.

1 Like

I wish I could at least make it click any of the mailboxes, which I can't at the moment.
From there, I would find a way, but for now, the script doesn't seem to click any of the mailboxes. :confused:

I think I'm getting closer :wink: Something like this will definitely help with the scrolling. I just have to create multiple conditions for each mailbox and then define which one is the first and which one is the last, and those would only have the option to scroll up or down:

image

Not the most elegant solution, but it's working :slight_smile:
Something like this:

And each action is just a simple click in a relative coordinate:

image

I think this is what I'll be using until I am able to upgrade the OS.

1 Like

Functionality trumps elegance in terms of getting stuff done!

:slight_smile:

-rob.

1 Like

100% Time is too precious to wait for the most elegant solution :slight_smile:
Thanks for the tip (clicking the location). Sometimes we forget the basics :wink:

Give this is a go -- it plays on the fact that the Edit->Complete menu item is only available when the Search box is active and the mailbox list is next after that in the Tab-activation cycle.

You may have change the "Pause", and could either duplicate the macro and change the arrow-key action to go the up the list or set two triggers and an "If Then" to chose up or down arrow.

Next Mail Mailbox.kmmacros (3.3 KB)

Next Mail Mailbox

1 Like

Ok for some weird reason, and totally by accident, I was able to make it work without KM.
I don't know if this is the normal behavior or if it's a glitch in Catalina, but for example when I click a mailbox, it doesn't turn blue:
image

When I click TAB a few times, and exactly after the Search box is in focus:
image

... the next thing in focus is the first mailbox:
image

Now if I click up and down arrows, it navigates them up and down, the same way the emails do... go figure...

So basically all I have to do is click the Search field to make it be in focus and then hit TAB to highlight the 1st mailbox, then just use the arrows up/down.
No KM macro necessary :slight_smile:

Funny and ironic timing that you and @Nige_S both posted the same thing independently :).

Playing around with what you discovered, in Sonoma, if the active mailbox is grey, pressing Shift-Tab twice will also turn it into the active blue highlight. Not sure if that works on Catalina or not.

-rob.

1 Like

I found that, in both Catalina and Sonoma, the number of Tabs required depending on whether or not an email is selected -- I know Danny suggests that the active mailbox will be empty when it's time to proceed to the next, but I thought it better not to chance it.

1 Like

Weird; on my Sonoma Mac, whether I have an email selected or not, Shift-Tab twice will always select the mailbox. Differences in full keyboard access settings, maybe? Doesn't seem logical, though. (I always have full keyboard access enabled.)

Of course, it's a moot point on Sonoma anyway, given the existing keyboard shortcuts.

-rob.

Try typing: ⌃⌘]

(control, command and the right bracket)

1 Like

Not ironic... I actually tried the TAB option, because I saw his reply and decided to hit TAB :slight_smile: I said it was "by accident" just because his macro seemed to be focused on something other workflow (or so I thought). My "accident" was just that I noticed that hitting it twice would highlight the mailbox.

In Catalina it only makes the Search be in focus, and then out of focus, but no mailbox is highlighted. But without SHIFT, I get that behavior I shared.

Funny that you call me "Danny" based on my old account :wink: My real name is Tiago. Danny is one of my stage names as a musician. But I'm good with both. I just find it funny :slight_smile:

Maybe I shared the "wrong" information about that, sorry. What I mean is that I like to have them all empty once I process my email, but that doesn't mean they will always be empty. If it's something important, I leave the email(s) there so I can go back to it/them later. I just like to navigate the mailboxes and see if there's something I can move to another folder or delete it/them.
So using this workaround of clicking the Search field first and then TAB once does the trick for me. That way I don't need another KM macro and another shortcut.
Or I can just click one of the mailboxes and hit TAB twice. That allows me to not even click the Search field.

Tha's the shortcut @griffman shared in the beginning, but that's not working in Catalina, unfortunately. Thanks for sharing though.

On my test Sonoma there's different tabs required depending whether or not an email is selected because of the preview pane -- with no email selected Tab toggles between mailbox list and current mailbox's email list, with an email selected it cycles through email list, preview pane, mailbox list.

(I keep this machine pretty near stock -- normally I'd turn off the preview pane.)

Also your home folder's name :wink:

That's sort of what my macro does, but I was so fixated on Tab-bing that I missed the obvious -- ⌥⌘F will activate the search box, making the macro much simpler:

image

OK, figured it out: It is keyboard navigation. With that feature disabled (System Settings → Keyboard), then I see the behavior you describe. With it enabled, I see the behavior I describe.

-rob.

1 Like

True haha