I found this very useful AppleScript to list all open tabs (works across multiple windows) for Chrome / Safari. Once you click on it, it will also automatically switch to that specific tab. (This is something I really really wanted). Technically, we’d have to use two scripts for the same, adding them below.
Chrome:
Chrome Tab Switcher.kmmacros (5.8 KB)
List all tabs
tell application "Google Chrome"
set tabList to {}
-- Get all windows
set windowList to every window
repeat with aWindow in windowList
set winID to id of aWindow
-- Get all tabs in this window
set currentTabs to every tab of aWindow
set tabIndex to 0
repeat with aTab in currentTabs
set tabIndex to tabIndex + 1
set tabName to title of aTab
-- Format: "WindowID,TabIndex__TabName" (Double underscore separator)
copy (winID as string) & "," & (tabIndex as string) & "__" & tabName to end of tabList
end repeat
end repeat
end tell
-- Return the list as text separated by new lines
set AppleScript's text item delimiters to "
"
return tabList as string
Save to a variable, in this example local_ChromeTabsRaw.
Prompt with list and show all available tabs.
Switch to the selected tab:
tell application "Keyboard Maestro Engine"
set selectedTab to getvariable "ChromeTabDest"
end tell
-- Check if selection is valid
if selectedTab is not "" then
-- Clean up the string if it contains extra text (just in case)
set AppleScript's text item delimiters to "_"
set cleanCoords to text item 1 of selectedTab
-- Parse "WindowID,TabIndex"
set AppleScript's text item delimiters to ","
if (count of text items of cleanCoords) is greater than or equal to 2 then
set winID to text item 1 of cleanCoords as integer
set tabIdx to text item 2 of cleanCoords as integer
tell application "Google Chrome"
activate
try
-- 1. Bring the specific window to the front
set index of window id winID to 1
-- 2. Switch to the specific tab index
set active tab index of window id winID to tabIdx
on error
beep
end try
end tell
end if
end if
Safari:
Safari Tab Switcher.kmmacros (6.1 KB)
List all tabs:
tell application "Safari"
set tabList to {}
-- Iterate through every window
set windowList to every window where visible is true
repeat with aWindow in windowList
set winID to id of aWindow
-- Iterate through every tab in the window
set currentTabs to every tab of aWindow
repeat with aTab in currentTabs
set tabName to name of aTab
set tabIndex to index of aTab
-- Format: "WindowID,TabIndex__TabName" (Double underscore is a separator)
copy (winID as string) & "," & (tabIndex as string) & "__" & tabName to end of tabList
end repeat
end repeat
end tell
-- Return the list as text separated by new lines
set AppleScript's text item delimiters to "
"
return tabList as string
Save to a variable, in this example local_TabsRaw.
Prompt with list and show all available tabs.
Switch to the selected tab:
tell application "Keyboard Maestro Engine"
-- Get the variable from KM
set selectedTab to getvariable "SafariTabDest"
end tell
-- Clean up the string if it contains extra text (e.g., "99678,1_ Name")
set AppleScript's text item delimiters to "_"
set cleanCoords to text item 1 of selectedTab -- This keeps just "99678,1"
-- Now split the clean coordinates into Window ID and Tab Index
set AppleScript's text item delimiters to ","
if (count of text items of cleanCoords) is greater than or equal to 2 then
set winID to text item 1 of cleanCoords as integer
set tabIdx to text item 2 of cleanCoords as integer
tell application "Safari"
activate
try
-- 1. Bring the specific window to the front
set index of window id winID to 1
-- 2. Switch to the specific tab
set current tab of window id winID to tab tabIdx of window id winID
on error
beep -- Beep if the tab no longer exists
end try
end tell
else
-- Troubleshooting: This runs if the format isn't "Number,Number"
display notification "Error: Could not read Tab ID" with title "Safari Switcher"
end if
Hope it’s useful!






