Browser tab tips—finding the tab you need

This seems obvious, so it’s a little embarrassing it took quite so long for me to stumble upon it. You have probably already figured this out.

I use KM a lot with browsers. Two sites are essential for my work and so I realized that ‘pinning’ them in my browser would mean they would always be present as Tab 1 and Tab 2.

This meant that I could then send my KM macro to the appropriate tab before doing its work, confident that:

  1. I would have the correct site; and
  2. I would not have to spawn lots of tabs.

However, with less-used sites, my macros (lazily?) opened a new tab before starting work and of course this sometimes leads to a sequence of tabs for the same site.

I did this because I thought there was no way of having KM looking at my open tabs to see if a site was open (unless it was the ‘front’ tab). Now I have realised that:

  1. KM will count how many tabs are open
  2. KM will step through tabs for me

This means that a macro can be written to step through tabs, looking at the title of each one and stopping when the title contains key words that I believe are unique to that site (e.g. for this forum the title contains Keyboard Maestro Discourse.)

I do this by getting to KM select the right-most tab and stepping back through the others until I have found what I need:

  1. Select the ‘last’ tab in my browser: Select Safari Tab SAFARITABCOUNT()
  2. Repeat the following action SAFARITABCOUNT() times:
    —IF title of Front Window contains %UniqueTitle% THEN do nothing (because I am on the correct tab)
    —ELSE : [nested IF statement follows]
    —IF SAFARITABINDEX()=1 THEN do nothing (because I have stepped back through all the tabs)
    —ELSE Previous Safari Tab
1 Like

Funny you should post this now. I'm just about to upload a macro to make this a snap, in both Safari and Chrome. I'll probably upload it in the next hour.

EDIT: Uploaded.

2 Likes