How Can I Include KM Macros in my macOS Spotlight Searches?

@peternlewis, or anyone, any ideas on how we might include KM Macros in macOS Spotlight searches?

Use Case

  • I have a lot of Macros that include some great scripts, and when I do a search I’d like to include these macros in the results list.
  • I also have both scripts outside of KM, and KM macros that provide a similar function, but the macro may not use any scripts.
  • The macro search would be based on the Spotlight qualifiers, like “name:”, “kind:”, dates, as well as contents if no qualifier is provided.
  • So I guess it would be much like combining the macOS Spotlight search with the KM Editor Search on “All Macros”

TIA.

1 Like

No idea I’m afraid.

One would have to create a custom Spotlight plug-in.

-Chris

I know this doesn’t solve all of the “use cases,” however, it might get you started?

Here’s what I do for Alfred and it also works for spotlight. Create a script that runs your macro (name it “KM app name”).

tell application "Keyboard Maestro Engine"
	do script "<UUID>"
end tell

Then save the script as an app. Yes, it’s cumbersome, but I honestly don’t see why it wouldn’t work. Alternatively, you could just have one script that triggers launch macro by name, thus you would type in “KM” or whatever and then it would open up that second macro

Thanks to you, @JMichaelTX, for showing me how to get the UUID earlier (I’ll leave it here in case anyone else wants it):

(menu Edit > Copy as > Copy as UUID)

I suppose you could probably add your own data to the app information so that spotlight can search it.

I was wondering, is there a way to treat a macro individually as an app? I’ll probably look it up later, but if there is, then you could bypass this whole solution.

Yep.

@peternlewis, both Evernote and Outlook do this to enable their items (notes in the case of EN) to be available to Spotlight. Could I request that you review this possibility to determine if it is feasible and cost beneficial?

Spotlight is very powerful and easy to use, and is one of the macOS features that Apple often promotes. I don’t know, but I suspect that macOS Siri may also draw from the same technology (Siri is just not fully implemented yet).

So, my guess is that this would be a significant promotion/marketing feature for Keyboard Maestro.

Noted.

1 Like

I looked in to this but I cannot find any API except one to allow you to import files in proprietary file formats. I don’t know if Evernote/Outlook keeps each note in a separate file or not, or whether they create some sort of “shadow” files for each item.

There is a wacky Python plugin API for spotlight, but that works via some weird SIMBL hacks, so that’s not really an option.

So unless I’m wrong about this and their is some sort of API I can’t find, it doesn’t look possible to me.

I have added macros to the spotlight index. “title:abc” works, and it includes more or less the full macro text to search so you should find scripts and such with it. I will see if I can make “kind:macro” work, so far I have not figured it out. And it includes the various dates in the field, but I don't know how to make spotlight actually search based on them (“modified:today” does not work for example).

3 Likes

This is excellent Peter! :+1:
So, I assume that if Spotlight finds a macro, a RETURN or double-click with run the macro, correct?
Would there be any way to edit the found macro?

Will this be a Ver 9 feature?

No, it will edit the macro, not run it.

Yes, it will be in v9.

2 Likes

That works for me -- it is my preference. We have two other good tools to trigger/run a macro by name.

1 Like