Script: Open Inspector Tab

This script attempts to open Tinderbox’s Inspector to the provided tab title.

Tinderbox’s Inspector got 31 subtabs. That probably just shows how powerful Tinderbox is. However, most of the time I only need a subset of the tabs. Clicking around in the Inspector often distracts me, especially when I’m trying to make something new work.

Alfred workflow

I’m currently using the script in a Alfred workflow that got

  • a search for all Inspector tabs
  • shortcuts for a subset of the tabs

Tinderbox - Open Inspector Tab.alfredworkflow.zip (63.8 KB)

Not sure whether I’ll stick to these shortcuts, it’s all new.

You can of course use any app that’s capable of running AppleScript with text input.

Hard coded version

If you’d like to use a hard coded version then use this

Script (hard coded)
-- Tinderbox - Open Inspector Tab (hard coded)
-- Note: Tinderbox's "Inspector" menu item got a different index across macOS versions. E.g. it's 16 on Catalina and 19 on Monterey. Those are already handled, but I didn't test other versions.

property theSubTab_Title : "Edict" -- Set the desired tab's title

property theSubTabsRecords_list : {¬
	{Subtab_Title:"Info", Subtab_Index:1, Tab_Title:"Tinderbox Inspector", Tab_Index:1}, ¬
	{Subtab_Title:"Agents & Rules", Subtab_Index:2, Tab_Title:"Tinderbox Inspector", Tab_Index:1}, ¬
	{Subtab_Title:"System", Subtab_Index:1, Tab_Title:"Document Inspector", Tab_Index:2}, ¬
	{Subtab_Title:"User", Subtab_Index:2, Tab_Title:"Document Inspector", Tab_Index:2}, ¬
	{Subtab_Title:"Colors", Subtab_Index:3, Tab_Title:"Document Inspector", Tab_Index:2}, ¬
	{Subtab_Title:"Links", Subtab_Index:4, Tab_Title:"Document Inspector", Tab_Index:2}, ¬
	{Subtab_Title:"Stamps", Subtab_Index:5, Tab_Title:"Document Inspector", Tab_Index:2}, ¬
	{Subtab_Title:"Prototype", Subtab_Index:1, Tab_Title:"Properties Inspector", Tab_Index:3}, ¬
	{Subtab_Title:"Quickstamp", Subtab_Index:2, Tab_Title:"Properties Inspector", Tab_Index:3}, ¬
	{Subtab_Title:"More", Subtab_Index:3, Tab_Title:"Properties Inspector", Tab_Index:3}, ¬
	{Subtab_Title:"Interior", Subtab_Index:1, Tab_Title:"Appearance Inspector", Tab_Index:4}, ¬
	{Subtab_Title:"Border", Subtab_Index:2, Tab_Title:"Appearance Inspector", Tab_Index:4}, ¬
	{Subtab_Title:"Shadow", Subtab_Index:3, Tab_Title:"Appearance Inspector", Tab_Index:4}, ¬
	{Subtab_Title:"Outline", Subtab_Index:4, Tab_Title:"Appearance Inspector", Tab_Index:4}, ¬
	{Subtab_Title:"Plot", Subtab_Index:4, Tab_Title:"Appearance Inspector", Tab_Index:4}, ¬
	{Subtab_Title:"Title", Subtab_Index:1, Tab_Title:"Text Inspector", Tab_Index:5}, ¬
	{Subtab_Title:"Subtitle", Subtab_Index:2, Tab_Title:"Text Inspector", Tab_Index:5}, ¬
	{Subtab_Title:"Caption", Subtab_Index:3, Tab_Title:"Text Inspector", Tab_Index:5}, ¬
	{Subtab_Title:"Hover", Subtab_Index:4, Tab_Title:"Text Inspector", Tab_Index:5}, ¬
	{Subtab_Title:"Text", Subtab_Index:5, Tab_Title:"Text Inspector", Tab_Index:5}, ¬
	{Subtab_Title:"Export", Subtab_Index:1, Tab_Title:"Export Inspector", Tab_Index:6}, ¬
	{Subtab_Title:"Markup", Subtab_Index:2, Tab_Title:"Export Inspector", Tab_Index:6}, ¬
	{Subtab_Title:"Style", Subtab_Index:3, Tab_Title:"Export Inspector", Tab_Index:6}, ¬
	{Subtab_Title:"List", Subtab_Index:4, Tab_Title:"Export Inspector", Tab_Index:6}, ¬
	{Subtab_Title:"Macro", Subtab_Index:5, Tab_Title:"Export Inspector", Tab_Index:6}, ¬
	{Subtab_Title:"Query", Subtab_Index:1, Tab_Title:"Action Inspector", Tab_Index:7}, ¬
	{Subtab_Title:"Action", Subtab_Index:2, Tab_Title:"Action Inspector", Tab_Index:7}, ¬
	{Subtab_Title:"Rule", Subtab_Index:3, Tab_Title:"Action Inspector", Tab_Index:7}, ¬
	{Subtab_Title:"Remove", Subtab_Index:4, Tab_Title:"Action Inspector", Tab_Index:7}, ¬
	{Subtab_Title:"Edict", Subtab_Index:5, Tab_Title:"Action Inspector", Tab_Index:7}, ¬
	{Subtab_Title:"Sort", Subtab_Index:6, Tab_Title:"Action Inspector", Tab_Index:7} ¬
		}



----------------------------------------------------------------- Get record ------------------------------------------------------------------

set theSubTab_record to missing value

repeat with thisSubTab_record in theSubTabsRecords_list
	if (Subtab_Title of thisSubTab_record) = theSubTab_Title then
		set theSubTab_record to thisSubTab_record
		set theTab_Title to Tab_Title of theSubTab_record
		set theTab_Index to Tab_Index of theSubTab_record
		set theSubTab_Index to Subtab_Index of theSubTab_record
		exit repeat
	end if
end repeat

if theSubTab_record = missing value then
	error "Couldn't find subtab in records"
end if

-------------------------------------------------------------------------------------------------------------------------------------------------

tell application "System Events"
	try
		tell process "Tinderbox"
			
			---------------------------------------------------------------- Get Inspector -----------------------------------------------------------------
			
			set theWindow to my getWindow()
			
			-------------------------------------------------------- If necessary open Inspector ---------------------------------------------------------
			
			if theWindow = missing value then
				tell application id "Cere" to activate
				repeat with thisMenuIndex in {16, 19} -- 16 auf MBP (Catalina), 19 auf Mac Studio (Monterey)
					click menu bar 1's menu bar item 9
					click menu bar 1's menu bar item 9's menu 1's menu item thisMenuIndex
					set theWindow to my getWindow()
					if theWindow ≠ missing value then
						exit repeat
					end if
				end repeat
			end if
			
			if theWindow = missing value then
				error "Couldn't find Inspector window"
			end if
			
			---------------------------------------------------- If necessary change Inspector tab -----------------------------------------------------
			
			if name of theWindow does not start with theTab_Title then
				click radio button theTab_Index of radio group 1 of theWindow
				set theWindow to (first window whose value of attribute "AXRoleDescription" = "floating window")
			end if
			
			--------------------------------------------------------------- Change subtab ----------------------------------------------------------------
			
			click radio button theSubTab_Index of tab group 1 of theWindow
		end tell
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "System Events" message error_message as warning
		return
	end try
end tell

on getWindow()
	try
		tell application "System Events"
			tell process "Tinderbox"
				set theWindows to (windows whose value of attribute "AXRoleDescription" = "floating window")
				if theWindows ≠ {} then
					set theWindow to item 1 of theWindows
				else
					set theWindow to missing value
				end if
				return theWindow
			end tell
		end tell
	on error error_message number error_number
		activate
		if the error_number is not -128 then display alert "Error: Handler \"getWindow\"" message error_message as warning
		error number -128
	end try
end getWindow

Note

  • As the script uses UI scripting it might not work on your macOS version out of the box. E.g. on my main mac (Monterey) the menu item’s index is 19 but on the old mac (Catalina) it’s 16. Please let me know if it doesn’t work.
1 Like

Thanks for sharing this. The AppleScript version is a nice extra for those using other tools for automation.

For rapid access ⌘+1 opens the Inspector; actually the shortcut toggles it open/closed. In a session, the Inspector opens by default at the Appearance Inspector’s Interior tab. Thereafter ⌘+1 toggle the Inspector at the last-sed tab/sub-tab selection.

The shortcut ⌘+3 is a toggle, directly to the Properties Inspector’s Prototypes sub-tab; this is essentially a historical legacy. The shortcut use to go the QuickStamp tab—less used these days—and that feature was a stand-alone window in the old pre-v6 app design.


Might I ask which tab(s) you use? I ask because, with very few exceptions, the controls on the Inspector just set attribute values, for instance. But, you might say, the attributes are listed by group both in the Inspector and in Get Info’s attributes tab.

How might we get a ‘custom’ list of attributes that we can edit in one place. Prototypes offer a solution. Though most people use prototypes to pre-set things (colours, user attribute values, badges, etc.), they can do something at simple as loading a customised Displayed Attributes table. So by setting (or changing) a note’s prototype you might quickly change the note’s Displayed Attribute. Be aware that changing the Displayed Attributes table simply changes which attributes you see , it doesn’t change the attribute values (unless you’ve customised the prototype to do so.

This doesn’t argue against or invalidate your method above. Far from it! Some people prefer to use pop-up controls in an Inspector rather than enter values—there is no single ‘correct’ method. Still, prototypes may, for some users offer an alternate method to resolving your starting problem of easily changing features in your TBX.

HTH

1 Like

Yes, I changed the default shortcut (to ⌥ + ⌘ + I) and assigned a key for it on my ErgoDox EZ keyboard. Customized the “info” shortcut across apps (e.g. in DEVONthink and Finder), so pressing a single key shows/hides an app’s “info”.

The Alfred workflow currently got shortcuts for these subtabs

  • Action
  • Caption
  • Edict
  • Hover
  • Interior
  • Links
  • Quickstamp
  • Rule
  • Stamps
  • User

Don’t need all of them, but those are the ones that didn’t conflict with other subtabs’ titles (which means there’s e.g. a shortcut for Rule but not for Remove).

Actually wrote the script with prototypes in mind. I have one template file in a git repo which I use as starting point for every new Tinderbox (via menu File > Open Favorites > Tinderbox template). Most often the things I need to do in a new Tinderbox are specific to the current task, however sometimes I develop some useful stuff (or enhance existing Prototypes) which I’d like to also have in every new Tinderbox. The script makes it easier to check different attributes’ values. It’s also handy for those times when I’m just playing around with attributes (e.g. colors).

Sadly, my system is unhappy with the shortcuts

image

Tom

How did you run the script (via Alfred or via Script Editor)? It might be that you’ll need to grant permissions in macOS’s System preferences.

What macOS version do you use?

I dropped the workflow in Alfred. I agree, I think it is a security issue. Where do I allow the permission? My alfred app already is checked.?

tom

Although using AppleScript every day I must admit that I still can’t tell exactly where to look if things (related to permissions) don’t work. It just happens too occasionally to really look into it.

Here’s what I have on macOS 12.6.1

We’ll definitely get this sorted, but it might take some back and forth as I really have no “plan” how to resolve such issues (just glad when things are finally runnig :slight_smile: ).

Thanks Pete, That worked.
Screenshots were really helpful. I needed to add Alfred to Accessibility.

Tom

2 Likes

Great!