1
votes

I have a many chrome windows open. Each chrome window has many tabs.

Right now I can only go to the chrome tab if what I want is the active tab by calling the name of the tab directly.

!t::
   WinActivate System - Google Sheets - Google Chrome
   Return

If the name of the tab is not active, nothing happens when I use the hotkey.

How do I get autohotkey to search through all the tabs and activate the one I want?

1

1 Answers

1
votes

I've used this function with mixed success. It sends CtrlTab until it either finds the tab title you want or until it finds a tab with the original title. I think you'll find an issue in your case if you have multiple windows in addition to multiple tabs. You may be able to tweak it to flip between windows as well.

; Activate tab in Google Chrome if it exists, return true/false if exist/doesn't exist
ActivateChromeTab(soughtTab)
{
  IfWinNotExist Google Chrome
  {
    return false
  }

  WinActivate Google Chrome
  WinWaitActive Google Chrome
  WinGetTitle, currentTab, A
  firstTab := currentTab

  if (InStr(currentTab, soughtTab) > 0)
  {
    return true
  }

  Loop
  {
    Send {CtrlDown}{Tab}{CtrlUp}
    Sleep 50
    WinGetTitle, currentTab, A
    foundTab := InStr(currentTab, soughtTab) > 0
  }
  Until (foundTab || currentTab == firstTab)

  return foundTab
}