Using dictionary/Lines collection variables with If Then Else conditions

Without wading through the subroutines -- it would help if you narrowed things down a bit! -- I'll hazard a guess that yes, it's the AppleScript.

Finder's AS Dictionary doesn't support tabs in windows. And a window's title is named for the currently active tab, so you can only match by title when the tab you want is active.

You have to use System Events:

-- tab name here
set tabName to "For Forum"

tell application "System Events"
	tell application process "Finder"
		repeat with eachWindow in (get every window)
			tell eachWindow
				try
					tell tab group 1
						click item 1 of (every radio button whose name is tabName)
						return
					end tell
				on error
					-- do nothing
				end try
			end tell
		end repeat
	end tell
end tell

Problem is, System Events doesn't know about window indexing so can't front the window. Luckily the window will now have the "correct" name so you can use KM.

Putting everything together:

Front Particular Finder Tab.kmmacros (3.5 KB)

Tested in 27.2 and written in a way that should make it easy to turn into a subroutine.

Apologies - I tried to be as descriptive as possible at each step about what step/action was intended to do what! :face_with_peeking_eye: I also wasn’t sure whether it was actually the AppleScript, or something random I’d missed with KM Actions in the next subroutine (for actually opening the Finder window).

That said, I've tried your script today - I think that works! Thank you!

If this would be helpful to anyone that is not me, I'll try and put up an actually useable version soon-ish. There's still a couple of sections I'm not quite happy with on that front though - particularly 2. Define window groups by parent path, which currently daisy-chains the group folder searches (for a parent folder) in a way that doesn't make for easy expansion. But it's the only way I've found to consistently set the grouped window a tab should open in and actually open it in that window - instead of moving it to a new tab because it's somehow not finding the match that very much exists...

My desktop and headspace thank you for your help with this :slight_smile: