KM Macro: Tbx Commander

This is a Keyboard Maestro macro group for calling up actions on selected tbx notes.


Set it up

  1. Unzip the file.
  2. Place the List of Commands.txt file at a location where it will spend the remaining of its days.
  3. Open the macro and head to the 01) Read this first macro.
  4. Type the location of the text file where the commands will be stored. (There is an example provided).
  5. Change the shortcut of 02) Tbx Commander.
  6. You’re set.

How to use

The macro works very much like a stamp.

  1. Select the notes it should act on.
  2. Type the shortcut.
  3. Choose an action

The following options are already built-in:

  • Add new command.
  • Edit command list.

The add new command option with call up a dialog for you to type the command. If you wish to save it for later use, give it a name/description in the next dialog box. It will then run the command.

The actions are stored in a plain text file, one command per line followed by __ (two underlines) and a brief explanation without any linebreaks. Here is an example:

£££__Edit file with commands
¢¢¢__Edit file with notes
$DisplayExpression='$Name+"  ("+$ChildCount+")"';__Display Expression:title & child count
$Name = $Name.replace("\n","");__Fix text:\n in name
var theText; theText = $Text; $Text = theText.replace("\n\n\n","\n\n");__Fix text:3 linebreaks → 2 linebreaks
$Name = $Name.lowercase__Fix text:Make title lowercase

File: Tinderbox Commander.zip (34.2 KB)

Keep in mind that this is a macro for running actions that may damage your notes and files.

Test it out in dummy files first and remember that you cannot ⌘z your way out of changes made by scripts!

Hope this is useful!

4 Likes

Very nice Bernado! Thanks for sharing!

I think I’ll be using this a lot as now there’s only one place to change commands (instead of curating stamps in one Tinderbox and updating them in other documents).

One minor thing: Users who don’t use the beta have to change this line

tell application "Tinderbox 9"

in macro “02) Tbx Commander”'s last action group to

tell application "Tinderbox 8"

And for those who are not familiar with importing macros: You first have to enable the macro group, with the macro group selected use menu View > Enable Macro Group (or the contextual menu).

Thanks again!

1 Like

Hey @Bernard-0 I’ve not been able to get this script working on Big Sur. @TomD and I just verified that it does not work on his Big Sur machine either. Have any ideas? @TomD has verified that it works on his Catalina machine.

I think it is unlikely to be an OS problem and more likely that you haven’t given Keyboard Maestro all the necessary permissions. The script itself is nothing special. For instance, try running this from script editor on some dummy note:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

tell application id "KM*E"
	set theCommand to ""
	set theCommand to value of variable "theCommand"
end tell


-- for testing purposes:
set theCommand to "$Name = 'Come to the dark side of the force and get a free cookie'"

tell application "Tinderbox 9"
	
	-- 	set theNote to item 1 of the selection in front document
	-- set theNotes to notes of front document
	
	set theNotes to selection in front document
	repeat with theNote in theNotes
		
		act on theNote with theCommand
		
	end repeat
end tell

Tom could not get it to work either on Big Sur, but could on his other machine. Other Keyboard Maestro scripts work for me.

Also, I don’t understand the note below. Is there an AppleScript needed for the TBX Commander? Maybe that is what I’m missing.

Verified. The same script (synced and verified) on my MacMini (Catalina) worked perfectly, Big Sur MacBook Air version failed. Nothing happened. Other KM scripts work fine.
This is my n=1

Not sure if anyone else on Big Sur has had success.
Tom

1 Like

Dear Mr.Bernardo Vasconcelos,
Thank a lot for distributing your Keyboard Maestro macro.
This macro is more than enough for the “string” search function I was looking for.
I was taking a refresher practice on Tinderbox while watching a VIDEO created by Mr. Michael Becker & awards, and I was wondering how I could “search” and create a “quote” or “link” to a “thought” from a Tinderbox file I had created. I have been wondering.
This macro does exactly what I wanted it to do.
Thank you very much for distributing such a useful macro.
Sincerely yours, Kunimitsu Wakamatsu
P.S
My environment : Mac OS10.14.6 Mojave, Keyboard Maestro9.2,
Tinderbox 8.5.1 & 8.6.2
Since I can use this macro, it looks like I do not have to narrow down to just one Emacs27 org-roam, which I was using together, and switch all my descriptions to Emacs27.

1 Like

Thank you, Mr. Wakamatsu (@WAKAMATSU), for your kind words.

I am using Big Sur, so that is not the cause of the problem. Did you try to run the script from Script Debugger or Script Editor? Also, did you try it on Tbx 8 or 9? The script is set for 9 as you can see, so if you were to try on Tbx 8 you would need to change tell application "Tinderbox 9" to tell application "Tinderbox 8".

The commands are passed to Tbx via Applescript.

Bernard, I’ve tried it on both 8 and 9. Understand the AppleScript. Have no idea how I’d apply a debugger.

Hi Bernardo,

I am running Big Sur with the Tinderbox 9 change and like MichaelB, it will not load… I did have an error in the Script Editor. See below…

Tom

For testing purposes, try this.

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions


tell application "Tinderbox 9"


    set theCommand to "$Name = 'Come to the dark side of the force and get a free cookie'"
	
	set theNotes to selection in front document
	repeat with theNote in theNotes
		
		act on theNote with theCommand
		
	end repeat
end tell

Here is what I get…

Tom

Strange. Perhaps @eastgate will know what could be the cause.

Just to confirm: The test script works here with Tinderbox 8.9.2 running under Big Sur 11.3.

When a script says it “Can’t get document 1” it is complaining that it can’t find the front document.

Assuming there was a Tinderbox document open, then this could be a security settings thing.

If you haven’t done so already, go to System Preferences > Security & Privacy > Privacy > Accessibility and make sure Script Editor and Tinderbox are listed and checked under ‘Allow the apps below to control your computer.’ (If they aren’t you’ll need to unlock the lock at lower left before making changes to the list).

If that is all in order, then try restarting your Mac.

SG

1 Like

Restarting worked. The script gave no errors upon restarting and having Tinderbox 9 open.

Tom