Is there a way to search macro specifically within comments with a specific title?

I have macros (such as a recent one created by @tiffle and many others by him and other forum members) which have instructional value in addition to solving an immediate problem.
In those macro, I create a comment entitled "Teaching". I was wondering is there is a way of listing the content of those comments so I can create some kind of personal teaching library.
thanks in advance for your time and help

Convert list of file paths in clipboard to list of file names - Questions & Suggestions - Keyboard Maestro Discourse

image

Basically, no.

Maybe you could process all the actions through AppleScript (or the plist macro file) and find all the comment actions and then search that, but there is definitely no way to do it within the editor.

1 Like

thank you @peternlewis . Your solution using AppleScript is beyond my competence.

It's pretty much beyond mine too.

1 Like

It is, as @peternlewis suggests, possible by employing AppleScript (maybe Javascript) and I already have a macro that could be used as a starting point…

What I have in mind is a macro that goes through all your macros and for each one that has a comment as either its first or second action (there is a reason for that!) it extracts at the least the comment title and text and the macro UUID for later use.

Now there are a couple of points to note:

  1. The macro would take time to run - the larger the number of macros you have the longer it would take. It might only be a few seconds but it would be enough to be annoying if it happened every time you wanted to perform a search.
  2. for later use” needs some thinking about: how and where would the extracted information be stored/presented/searched/filtered?

Based on these two points in my opinion the macro I’ve been talking about would be best run once every so often (manually or on a periodic basis) in order to index so to speak your collection of macros; the result of the indexing would be stored in a file/spreadsheet/database. You would then use another macro or app to search through the index and produce the searched-for information and that would be a very fast operation.

This then brings me to this question: what do you want to do with the result of the search? Do you just want to read it? Or maybe have the ability to examine the one or more macros that have been found by the search operation? Would the indexing macro need to have created and saved images of all your macros so you can examine those instead of opening up the actual macros in the KM editor?

I’m now getting a little worried that this is actually potentially much more complex a task depending on what you wish to do. All comments welcome!

2 Likes

how about limiting the search to a smart group ? The percentage of teaching macros is infinitesimal compared to the total number.
Results . clipboard would be fine.
thank you

If I remember correctly from a post last week, as of right now, AppleScript can’t search through smart groups, however Peter has indicated that this will be a capability in the next major version.

EDIT: Found Peter’s post about this.

3 Likes

Just tinkering with a bit of AppleScript I noticed that the contents of the Comment action are in styled text - which is not readily searchable unless it is first converted to plain text. (Good luck with that!)

However, as always, JMichaelTX is smiling down on us having foreseen this need and he posted his approach in this thread:

I've just tried out his macro and it does work and perhaps with a little fine tuning @ronald it can be made to work for you...

Try it out to see how it fits your needs.

3 Likes

For me it works, Thank you!

2 Likes

Comments are useful for reminders about what actions and macros do, for crediting creators of macros and so on. I do not think they are well suited to being notes for a personal knowledge management system, which is what I imagine your "personal teaching library" to be.

May I suggest that you keep notes about each macro in a in a text file, or better still a PKM application. If you use, for instance, Obsidian, you can even have links between separate notes.

I think you would find such a ready reference convenient, easy and useful, and you wouldn't have to try to make Keyboard Maestro do something it's not designed for.

3 Likes

a very good point. thank you. In fact I am trying to create some kind of index which has nothing to do with KBM.

2 Likes