MACRO: Spotlight Search Prompt

@JMichaelTX - Can you test this macro on Yosemite, and double-check that the above issue is the only one? I’ll post an updated version, if you can verify for me.

Thanks!

Hi Dan, thanks for the unvaluable “framework”.

I have a feature request:
provide a new option to return the exact string typed in the search field when the user press the Custom Button (now you can specify a fixed string).

Feasible?

P.S. A keyboard shortcut for the Custom Button would be also much appreciated

LOL. I hope you meant "invaluable". :smile:

[P]rovide a new option to return the exact string typed in the search field when the user press the Custom Button (now you can specify a fixed string)

I can do that. I'll add a variable called "sspResultSearchText", or something like that.

A keyboard shortcut for the Custom Button would be also much appreciated

I'm pretty sure that's feasible. The docs say the default modifiers are Ctrl+Alt, which seems strange to me, but I guess it might make sense because you wouldn't want to conflict with Cmd+C, etc. Are you OK with Ctrl+Alt+key?

Invaluable, definitely!
Apologies for my bad English and/or my aversion to spell checking :kissing_closed_eyes:

No problem for me with this combination. Probably the best solution would be to have the shortcut automatically generated with the first letter of the button name (e.g. button "New" shortcut ⌃⌥+N) but only if it's not going to be the source of possible conflicts.

P.S. Since I already made some small customisations on your macro set, could you please specify the modified files/macros in case you want to post a new version? This way I can substitute the changed stuff without restarting from scratch.
Thanks again!

I'm going to follow KM's standard for the regular Prompt action, which is to follow the button text with "/key" as in "/F" to specify the shortcut. Hope that's OK.

Could you please specify the modified files/macros in case you want to post a new version?

Absolutely.

I'm double-checking about the Ctrl+Alt modifiers. I should be able to make these changes relatively soon.

This should work for you, for now.

Spotlight Search Prompt Resources.pkg.zip (501.9 KB)

Unzip this file. Once you do, you'll have a new Resources package file. Remember, DO NOT DOUBLE-CLICK the .pkg file. :slight_smile:

Move or rename your existing resources package file, and put this new one where your old one was. Let me know if you have questions about this.

For these changes, the Macros themselves haven't changed.

##Changes:

  • Fixed issue that caused an error message under Yosemite, on some systems.

  • Redesigned the Help HTML file, because there were issues displaying it on some systems.

  • Added the ability to specify a keyboard shortcut for Custom Buttons. This works similar to the standard Keyboard Maestro "Prompt for User Input" action:

  • Specify the custom button text like this:

"customButtonText: Edit/E"

  • In this example, the keyboard shortcut for the "Edit" button will be Control+Option+E.

  • If you hover the mouse cursor over the custom button, a tooltip will show you the keyboard shortcut.

  • When the OK or Custom Button are clicked, whatever the user had currently typed in the Filter box will be returned in the variable "sspResultFilterText".

PS to anyone following along:

I’m not going to release version 1.1 yet, meaning I’m not going to replace the original v1.0.zip file.

I have an upcoming project that I hope will help automate the process of updating existing macros and resources, and I’m hoping to use it to release v1.1.

@JMichaelTX -

I have a new HTML file. Can you see if this solves the problem you had? I completely redid this one. I used Markdown in Quiver, and exported it as HTML.

  • Grab the zip file from a couple of posts above.
  • Unzip the .pkg file
  • In Finder, “Show Package Contents”
  • Navigate to the “docs” folder.
  • Open “Spotlight Documentation.htm” in Safari and see if it displays OK.

Thanks!

Hi Dan,
thanks for taking the time to modify the resources files. Much appreciated.

I made a few changes on the If block at the end of the Spotlight Search Prompt sub-macro (the action that cancel the sub-macro if needed; see also attached screenshot).
Just want to inform you in case you think they could be added to you "master copy":

  1. Removed the condition sspResult is empty: using the Custom Button leaves that variable untouched (i.e. empty) so the cancellation was incorrectly triggered (that's a temporary workaround; see below)

  2. Added deletion of variables sspResult and sspResultButton in the "Cancel" branch of the block (so they're deleted when cancelling the sub-macro as well)

  3. Moved deletion of variable sspCancelMacroIfCancelClicked outside (after) the block so tha variable is deleted when pressing OK button as well

A glitch was introduced by the deletion of the sspResult is empty condition: when cancelling the prompt using the default shortcut ⌘+. the variable HTML Result Button is not set to "Cancel" so the cancellation in the If block is not triggered.
This could be avoided reintroducing the above mentioned condition but that requires the sspResult to be set to something like "(none)" when the prompt is closed using the Custom Button.

You're right, there is a bug, but I think there's a better solution. Use this instead:

  • Instead of checking "HTML Result Button" for "Cancel", check "sspResultButton".
  • Remove the check for "sspResult" being empty (as you've already done).

I believe this will solve the entire issue. If you look a the code for where "sspResultButton" is set, you'll see it gets set to "Cancel" if there is no value in "HTML Result Button" - which is what happens if you press Escape or ⌘+.

I hope this makes sense. Let me know if you understand, and if it solves your problem.

And thanks for reporting this issue!

Your fix worked fine and now the Spotlight Search Prompt sub-macro exits in the correct way for every possible case.

Thanks again for your macro and your assistance!

1 Like

Done for the next version (although not as thoroughly as @DanThomas’s macro).

6 Likes

Wait so KM will have its own native spotlight search prompt in next version?

No, it will have a native version of what @DanThomas’s macro does, it let you select from a list with a spotlight-like interface. Similar to the Add Action by Name interface, but with your supplied data.

1 Like

That would be amazing. As currently Dan Thomas’s macro is amazing as it is but it has a rather annoying startup delay. Since I use this macro very often, a native solution would be so great.

Thank you @peternlewis

Dan, your original post at top is still at Ver 1.0. Did you ever make an official update to Ver 1.1?

I have made a number of mods to whatever version I had, which I assume is/was Ver 1.0. How can I tell for sure?

Nope, I never released another version. And on my computer, at least, the macro “Spotlight Search Prompt” says what version it is.

I would like to dynamically create a palette (or some sort of search/selection interface) based on the contents of a specified folder. I've begun looking at Spotlight Search Prompt as a solution.

Am I on the right track, below? I think the plan would be...

  • Get the contents of the specified folder using For Each Path in Folder.
  • Get the Path of each item in the specified folder and append to sspData variable.
  • Get the base name of the file, or the last path component if the item is a folder, as a separate field to search on and select from. (Might be nice if the full path were even part of the search.)

If this is a good plan?

If so, I have a question: How do I get the data in the sspData variable formatted properly so that the item names are what is searched but the path for the selected item is the result...so that I can have KM maestro open that path?

Take a look at the example macros that @DanThomas provided in the Spotlight Search Prompt Macro Group (installed when you import Dan's macro). I found the examples/instructions very clear and helpful.

image

1 Like

Yes! Thank you! Example 2 will provide a good start. The path takes the place of the ID#. The item name takes the place of the Name. Thanks!

1 Like