Spotlight General Purpose Search (macOS)

The first click shows it all on the window, the second click shows it at full size. That seems a reasonable sequence to me in general. Clearly, for a very large image like this, the first click, all on the window probably wont work for a macro, but it would work fine for an image without text in it.

I agree. I just didn't know how to do that.

If you, or anyone, knows how to specify the date format that uses the user's local settings, I'd be glad to revise the macro to use it.

A line of AppleScript can be a solution, e.g.:

set mydate to short date string of ((current date) - 2 * days)

PS: What software have you used to make the composite menu screen shot [1]:

Snagit is what I have used for years, with both Mac and Windows, to do all of my screen capture and annotations. I highly recommend it. It's also useful for quick videos to demo app behavior.

Thanks JM I will give a try.
-- Alain

Beautiful (and impressive) macro! I noticed one key bug (I'm using MacOS 10.13.3 with KM 8.1.1; both are the latest versions as of the date of this post):

When I specify "None" in the SLKind field, it works fine. Here I've created and searched for some test documents containing "foox" in the filename:

But when I specify a file type in SLKind, e.g., "PDF", it appends a period to the search term (see "name:foox." at upper right) which means, in the case pictured here, that it's searching for "foox." rather than "foox"; as a consequence, it doesn't return any results:

To get the search results, I need to manually delete the period:

Using "Microsoft Word Document" instead of "PDF" in SLKind creates the same issue.

Sorry, I am unable to reproduce your behavior. I see nothing in the macro that would append a period.

But I am running Sierra, as opposed to your High Sierra:
Keyboard Maestro 8.1.1 (8.1.1) on macOS 10.12.6.

image

image

You might check the KM Variable "SLSearchTerms" in the KM prefs:

image

Just posted an update to the OP.

Thanks for your reply. I checked this, and the extra period that shows up in the search box isn't present in SLSearchTerms (see screenshot below).

One other minor difference I've noticed on my system is that your instructions say, for the fields in which you aren't imposing a search restriction, that you can either leave them blank or enter "None." I've found that, if any are blank, the macro doesn't work -- all non-restrictive fields need to say "None." This is not an issue in practice, since once you've entered None you never need to do so again (unless you apply a restriction). So I only mention it in case it gives another clue about what might be causing the divergent behavior on my system.

I also tried your new version of the Macro, and it doesn't work at all on my system (with either SLKind = PDF or SLKind = None).

So there's three possibilities for why I'm seeing different behavior from you:

  1. Different OS version
  2. Some difference in the way my system is configured, external to KM.
  3. Some internal conflict between your macro and one of my other KM macros (don't know enough about KM to know what that might be, or if such a conflict is even possible [since none of my other macros use the same trigger]).

Then the period is added when the KM macro is typing the SLSearchTerms text into the search box. Perhaps you have a maco that is being triggered, or a text expander, or even a macOS text substitution which is inserting the period.

Please double-check your System Preferences > Keyboard > Text to make sure "Add period with double-space" is unchecked:

image

Could you please more specific? Is the macro not executing, or exactly where does it fail?

1 Like

Yup that was it! I unchecked that and now everything is good (with the old macro).

1 Like

So if I run the new macro, I get a clunk sound followed immediately by the hero sound, and nothing is inserted into the Spotlight search field. Likewise, if I run the old macro, then delete what's in the Spotlight search field, same thing:

But if I first run the old macro, and then immediately run the new macro, rather than replacing the old search term with the new, it appends the new search term onto the old search term:

Alternately, if I first create the Spotlight search manually (instead of using your old macro), and then run your new macro, I observe the same appending behavior:

In other words, if the Spotlight field is blank, the new macro doesn't insert anything into that field. But if the Spotlight field has a previous query in it, it appends the new query to the old query.

Finally, the behavior I describe above is independent of whether I'm using SLKind=PDF or SLKind=None.

The "clunk" sound probably means something has failed. Did you notice an KM failure/error notifications?

You might need to increase the Pause time near the end of the macro:

image

My prior version has this set to 1 sec.

Increased it to 1.0 sec., didn't see any error messages.

Also, I noticed that the first time I run the new macro after rebooting the computer, I only get a clunk. All subsequent executions give clunk+hero.

There is one way I can get the new macro to work: First, run a general Spotlight search (just enter something -- doesn't matter what--into the field next to the magnifying glass). I.e., I haven't opened and filled the special subfields for restricted searches. Then run the new macro. What happens here is I get clunk+hero, after which it returns a correct search.

Maybe this is something that High Sierra broke. I just tested Ver 2.0 of my macro on another Mac running Sierra, and it works fine.

The macro does assume the following shortcuts for Spotlight searches:

  • ⌘SPACE for normal SL search
  • ⌃SPACE for Finder SL search

If you are really interested, you could step thru Ver 2 using the KM Debugger.

1 Like

Yup, that's it! I had different shortcuts set up for SL searches. When I restored them to what you specified, your new macro worked!. The key issue seems to be that the default for a Finder SL search in HS is option-cmd-space, not ctrl-space:

However, the problem is that making these changes broke the old macro! So I'll just go back to my old shortcuts, and continue using the old macro.

1 Like

Hi. this macro doesn't work for me. Is that because of the version of KM? mine is 7.3.1. Also I would like to search my tags. is that possible?

I seem to be repeating myself lately:
We're pretty good around here, but we have not quite mastered reading minds, yet. :wink:

For us to help you, you have to first read and follow this:
Tip: How Do I Get The Best Answer in the Shortest Time?

Thanks.

You are right. I do apologize. The macro worked only one time for me. The macro opened my Finder and typed slowly my text on the search bar, but after that, it doesn't run.
KM 7.3.1
macOS 10.13.3

This could be an issue with High Sierra. I think KM 7.3.1 is OK.
It still runs fine for me in Keyboard Maestro 8.2.2 on macOS 10.12.6.
I have no way of debugging for 10.13, since I don't have access to a machine running that.