Detect number of tabs In an app? For tab-switching

I'm using this app called Glyphs Mini, would like to use these commands to switch between tabs:
Cmd-1 - goes to Tab 1
Cmd-2 - goes to Tab 2
Cmd-3 - goes to Tab 3

ran Window Analyzer but Applescript is not supported:


Glyphs Mini -- Window Properties Report -- 01 Windows Listed

Window 01                  :  New Font-Regular - New Font

position                   :  0, 23
size                       :  1440, 837
subrole                    :  AXStandardWindow
role                       :  AXWindow
focused                    :  false
title                      :  New Font-Regular - New Font
role description           :  standard window
description                :  standard window,
class                      :  window
accessibility description  :  missing value
enabled                    :  missing value
help                       :  missing value
maximum value              :  missing value
minimum value              :  missing value
orientation                :  missing value
selected                   :  missing value
value                      :  missing value

so my next thought was: KM can do it!

If I have only 2 or 3 tabs opened, it works because I'm using the overlapping area which tab #2 occupies when there are 2 or 3 tabs.

So far so good.

But, what if I have Four tabs?
It breaks because Cmd-2 will click the area where Tab #3 now resides:

Lowest tech solution so far I can think of, minimal effort required:
Always use four tabs, no less, so Cmd-1 to 4 will always click in their respective location.

Any other ideas?

I also tried with UI scripting but the “tabs” somehow are non-existent.

Yes. But beware, it’s a “creative” experimental approach :upside_down_face:

The idea is to use the built-in standard shortcuts for cycling through the tabs (⇧⌘] and ⇧⌘[):

Select Tab by Number <44B3 200225T190504>.kmmacros (9.1 KB)

Basically it goes like this:

You press one of the hotkeys (⌘1, ⌘2, etc.) and the corresponding tab will be selected.

When you run the macro the first time:

  1. Select tab 1 in Glyphs Mini (important)
  2. Run the macro, for example ⌘3 to go to tab 3

As long as you want to use the macro you must not select a tab manually. Never. If you look at the macro, you’ll understand why: the calculation of the difference of current tab and desired tab will be messed up.

If you have messed up, you can recalibrate the macro at any time by doing this:

  1. Select tab 1
  2. Press ⌘0


nice, very, very, VERY creative way to solve it Tom :man_dancing:

I was thinking about doing some calculations to divide the space x number of tabs, but this approach is much more "native".

Just trying it and works great
You rock! Thanks @Tom!!

1 Like