MACRO: Execute (Trigger) Macro by Name (Spotlight)

OK, I opened the HTML file and saw that.

But somehow it's not reading the KM variable correctly.

Here's where I made the change:

BTW, I have two monitors. Could that have an effect?
It is always displaying the window on monitor #2.

Then maybe you’re running into the same issue I did.

Without setting the variable, try dragging the window somewhere else and clicking OK or Cancel (NOT escape). Then check the value of the variable. Does it change? If so, then it’s the right variable.

It’s not an issue with multiple screens - I have multiple screens, and it works on my machine.

As I said previously, try it a bunch of times, dragging the window around, etc., and see if it suddenly starts working.

If that doesn’t work, let me know, and I’ll show you how to debug it.

It looks like you are storing the last window position in this KM variable:
DND__embnWindowPosition

It changes when I move the window and click OK.
DND__sspWindowPosition does NOT change.

When I set DND__embnWindowPosition it works:

Oh, cool. Shows what I know. :slight_smile:

You actually set the KM Variable name in "sspOptions":

1 Like

LOL. Thanks for the sleuthing. I totally forgot that!

Thanks for this one: you guys are just great. I just found it via 'Jim' from another topic.

1 Like

Hi @DanThomas,

Thanks again for making all these amazing tools.

Sorry for reviving this old topic. I'm still using this macro quite often.

Just a quick question, is there a way to let the prompt window remember my last search string?

image

I'm not sure how to do it. The macro uses "Spotlight Search Prompt", which may be used by other macros. I don't know which HTML file to modify. As far as I can see, the only HTML file involved is Spotlight Search Prompt.html in the Spotlight Search Prompt Resources.pkg package, but it does not look the one I'm looking for.

Thanks!

I can't think of a built-in way, at least not an easy one. But I would think you could have a macro that displays the prompt, then automatically types text into the search field.

1 Like

I don't know if this helps with the Spotlight version, but I managed to cobble something together using the native Trigger macro by name action.

Trigger By Name (Remember Last Choice).kmmacros (23 KB)

Macro screenshot

I'm sure there's a more watertight way of capturing the name of the most recently run macro, but it seems to work in practice.

1 Like

Ok. Thanks! This seems to be an easy workaround. I was thinking of putting a js function to do something like this: if the triggering macro is Execute (Trigger) Macro by Name (Spotlight), then put the previous search string in the search bar.

Hi @noisneil,

Thanks for jumping in. But I was not searching for the last run macro; I was looking for the last search string I put in the search field, which may or may not be the same from the last run macro.

For instance, I searched for string "A", found a list a macros, then chose one to run or edit, then I move on to do other things or run some macros, then I come back to launch this Execute (Trigger) Macro by Name (Spotlight), and would like to have string "A" showing in the search field.

Yes, that's what it does. By "last run macro", I meant "last chosen by the Trigger macro by name macro". In other words, the previous choice appears in the search field, which I think is what you were after...?

Ah. Thanks.

I tried it out (needed to remove the macro group for the Trigger Macro by Name actions).
image

It generally works as I wanted. However, there is one minor issue:

If I use Esc (intended to cancel the search), KM will first delete the search string, then with another Esc to cancel the macro. In this case, the DND__LastMacro is also cleared. So, next time, when I run the macro again, it will be empty. But I'd like the macro not to clear the value of DND__LastMacro when I hit Esc (twice) to cancel the macro. Is there a way to do that?

Thanks!

I'm sure there is, but unfortunately I'm unable to help at the moment, as I'm having issues with KM crashing (which is incredibly rare, so don't worry!). I'm sure someone else can chip in.

Installed a macro as recommended in the readme file.
(Moved .pkg file into another location, run Spotlight Search Prompt Documentation, it asked for a path to the .pkg file, I provided it)

Now it gives me an error with every run:

When running Spotlight Search Prompt:

When (re-) running Spotlight Search Prompt Documentation:
Screenshot 2023-12-15 at 11.39.46 AM

How can it be fixed?