Feature Request: Toggle Comment Actions in Editor

On occasion, I'd like to suppress viewing Comment Actions in the Editor so as to focus on the logic. I could bury info in action-specific notes, but that's no fun.

1 Like

Could you just collapse the comment actions themselves? That's what I do...

See an example here (click to expand/collapse)

Yes, but I'd like to do that all at once for all Comments in that Macro.

You can do something like this:

tell application "Keyboard Maestro"
   set theMacro to first macro whose selected is true
   tell theMacro
      tell (actions whose name contains "comment")
         set disclosed to false
      end tell
   end tell
end tell
2 Likes

Christopher,

The AppleScript code can only collapse comment at the top level actions, is there a way to collapse all comments (including those at nested actions eg If-else action)?

Yes there is: just write some code (AppleScript or JXA will do) to recursively “walk” through a macro and act accordingly when it finds a comment action.

I’ve done this - the recursively walking through bit - for another private project and demonstrated its use for other purposes in this thread for example;

I also use this technique to “prettify” macros (changing colours and renaming macro parameters), to error-check macros and a variety of other stuff in the Checkpoint system I released some time ago to aid with KM debugging.

If there’s a serious request for this, I’ll produce a macro to achieve it since I already have the code to do it but I’m not inclined to waste time on a whim.

You can roll your own @macdevign_mac but as we’ve discussed in other threads, it’s not trivial :smiley:

3 Likes

Tiffle,
One of my requests to Peter is the ability to expand all actions for current macro, unfortunately this is not done. This feature is very useful especially for long macro where users want a fast way to expand all actions (including nested actions).

I thinking of rolling my own but like to check if others have already done similar work, and could share the source code (in case need custom change) :} .

I can't do that as the code base is proprietary.

However, I can share the compiled AppleScript and a demo macro to do what you want.

Here's the compiled script:
Switch KM Action Disclosure.scpt.zip (2.7 KB)

You'll need to unzip it to a convenient location. For my demo, I just put it on my Desktop.

Here's a macro that demonstrates the script's usage. You need to change the script's location in the Execute an AppleScript action to correspond to where you've unzipped the file.

Once you've done all that, just select the macro that you want to work on in the KM Editor and trigger this demo macro to see it in action.

Test Switch Disclosure.kmmacros (2.7 KB)

Expand to see image of macro

Keyboard Maestro Export

tiffle,
This works great. Able to expand every actions reclusively.
This should have been the standard feature of KM.

thank

1 Like

Tiffle,
I notice that for large macro, the expansion could be noticeably slow. Just checking if your script only expand the action if the action is collapsed, or expanding all actions regardless of their 'disclosed' status ?

Just 2 comments on that:

  1. Every action in the macro is visited and expanded/collapsed as directed regardless of its current state.
  2. The script is a recursive AppleScript.

Point 1 is not the only reason the script can appear to be slow since I'm not an AppleScript expert and I don't know how to squeeze the maximum performance out of it :frowning:

Besides which I took your request literally:

If you don't like it, you can always ask for a refund :wink:

1 Like

Just thought I'd mention that option-clicking one disclosure triangle collapses/expands all actions/groups on the same group level. By group level, I mean grouped actions or groups.

Not really relevant to your request, but thought I'd say in case anyone had missed it.

2 Likes

Extremely helpful to me, thank you! And very close to my ideal solution, I just need to grok a little something about Applescript before I get there …

2 Likes

tiffle,
I have built my own version using Applescript, and found that performance is noticeably improved if the disclosed property is set only if necessary.

It is a lot of work with many trial and error as I'm not a Applescript person, but I'm just do it out of curiosity and learning foremost. Anything that saves time is worth the time :} . The code is not actually long.

I share the code once it is fully tested. There might be some edge cases that I may miss but so far, it works great.

thank

3 Likes

Cool :+1: do share it if you can!