MACRO: Abbreviation-Based Web Searches

Yep, that's how you do it :).

-rob.

Hey Rob,

Do you have any plans to allow simultaneous searches on multiple websites?

I currently have no idea, how to fire them. Perhaps via groups?

Perhaps this would be a useful addition/setting for other users too:

  • If GetClipboardContent=True then the clipboard content is pasted and selected in the Search field.
  • The user can press :arrow_upper_left: and type 'w ' to search the word in the Wikipedia, or
  • The user can just start typing, overwriting the selected text.

I do not—that would be an implementation nightmare. In theory, you could do it by allowing something like...

shortcut1#SEPARATOR#shortcut2#SEPARATOR#shortcut3 search terms

Where #SEPARATOR# is something that won't ever be in a shortcut, i.e. a couple of unicode characters or something.

However, implementing that is not something I want to even consider doing, given the amount of work involved and my personal lack of need for such a feature. If I have to search multiple sites, I'll just send it to DuckDuckGo :).

-rob.

This would also be something of a nightmare to implement, especially with automation where a user might not have on the clipboard what they think they have on the clipboard. Given you can use the clipboard by pressing Command-V in the input box already, that's easy enough access to the clipboard for me.

-rob.

1 Like

Yes, but what if the user has some text selected and then launches your shortcut? That would be a more intentional user step and be very handy. (This would be in the spirit of PopClip for Mac.)

I use that approach in a shortcut I created and use many times a day (and even while typing this post :grinning:): Augment or Filter Text

More recently, I added that feature to Log It. If you are interested, the logic might be easier to follow in that macro.

I still think it's too much complexity to add—I'd have to borrow your code to find a selection, which isn't something that's trivially done, versus just asking a user to press Cmd-C before they launch the macro.

(It'd be great if you could rely on the presence of the Copy menu item to determine a selection is active, but many apps ignore that practice now.)

As it is now, the logic already has too many layers to make me comfortable, and I don't want to further complicate things. If someone wants to do so on their own, more power to them ... but it's more complexity than I want to manage :).

-rob.

1 Like

Fair enough. Beggars can't be choosy! :rofl:

I agree it's not bullet-proof, but I'm generally using both in the context of a browser, so it almost always works.

Sadly, I usually use in the context of a text editor, and it fails badly with VS Code.

-rob.

Ah, Microsoft and Electron! :frowning: Didn’t know Mac developers were allowed to have that installed.

Maybe you need a Patreon page to raise money for BBEdit. :wink:

Hehe. I'm not our developer, Peter is. I do the all-but-code, basically. I love BBEdit for many tasks (it updates my macOS release dates blog entry), but it's serious overkill for simple tasks, and because it's so feature-rich, the menus are long and complex.

-rob.

1 Like

I'm totally jumping in blind here - I didn't read any of the previous comments. The only reason I'm even here is this is one of those threads that won't die, so I decided to see what everyone was talking about. And you're talking about one of my favorite subjects! Text and Code Editors!

I was a Windows developer for most of my life (I'm retired now), which means I know how much there is to dislike about Microsoft and Windows.

But one thing Microsoft knows how to do is make IDEs. Working in Visual Studio was a joy, and I'm thrilled to have VS Code on my Mac. I have nothing bad to say about it, and that's saying something. Wait.. ah, you know what I mean. :laughing:

I recently had to install VS Code in a couple of Parallels virtual machines (running various macOSes). Using their Sync Settings feature, it took next to no time at all. I LOVE VS Code.

Maybe you need a Patreon page to raise money for BBEdit. :wink:

I love BBEdit too, and it's my go-to for when I'm not developing something in VS Code. There's no reason not to have both.

Sorry about the rant - it's just that I've spent the last month and a half coding a complex Custom HTML Prompt using VS Code, so it's near and dear to my heart.

I have both too, I was just having a little fun with @griffman.

Regarding MS software, I've used Excel (heavily) throughout my engineering career. And in general it's not as easy to poke fun at them because they're actually putting out some great stuff, e.g., VSC, Power BI. Fortunately there's Word and it's as bad as ever. :wink:

@griffman, you might be sick of this topic by now, but for the record—the selection technique used in Augment or Filter Text and Log It works fine in VSC. I wonder what's different for you.

Getting Selected Text.kmactions (9.3 KB)

Macro Actions-image

Sorry, didn't mean your method, I meant my method of just checking for the Copy menu's active status. I prefer not to copy stuff to the clipboard unless needed—on my Mac, that launches the decrufting macro (which bails quickly if it's not a URL, but it still launches). I like the Copy menu method because it's totally passive.

-rob.

1 Like

Thanks for the clarification. I hadn't thought of that. That The system clipboard changes comes at a price.

But, you've go me thinking—maybe I should put a warning in my macros that temporally use the System Clipboard (and, if used, restore in with Delete Clipboard 0.)

No kidding. I finally switched to LibreOffice, and I couldn't be happier.

1 Like

Thanks Rob, I understand. I'll try to come up with my own macro for multi searches.

While not nearly as fancy as Rob's impressive macro, it's not too hard to put together something that can do multi searches:

[Example] Copy Selected Text and Search Multiple Sites.kmmacros (2.3 KB)

2 Likes

While it may seem I've been quiet lately with Web Search via Shortcut, that's not the case at all. It's just that I was frustrated by how hard it was to keep my own copy of the macro customized, given how often I was updating it, and having to always have a clean copy ready for distribution.

So I set out to rebuild it from the ground up, with a few objectives:

  • Speed. While the old macro wasn't all that slow, there was just a bit of a delay between invoking it and seeing the input dialog.
  • Shortcut Management. It's a real pain having to open the Keyboard Maestro editor and directly update variables to make changes to your shortcuts. And it's a real pain when an update comes out, and you have to copy-paste all your work between the old and new macros. I wanted to get rid of all that.
  • Ease of use. This is tied into easier updating of your shortcuts, of course, but I wanted an easy way for users to be able to add shortcuts without having to go dig up their own.

So instead of trying to make 2.5 do all of those things, I threw away pretty much all of it except for the actual input processor, and started working on 3.0. It is not quite ready, but it's close, and I'm looking for some testers — if you'd like to test it, just reply here and I'll give you the URL. Do not delete your existing 2.5 macro, just disable it (or assign it to another shortcut).

It addresses all of the above; here's a teaser for the speed side—this is how long it takes for the dialog to appear after you hit the hot key:


The new input dialog appears basically instantly, over 5x faster than the old. And as for management of shortcuts, that's now 100% within the macro, not in the editor at all:

The current version is nearly fully functional, but it needs a lot of polish, as well as some how-to instructions, etc. But I'd like others to use it, to help find things that I know I've missed. So reply here or message me, and I'll send you a link and some basic instructions.

Many thanks to @Lantro for his invaluable assistance in getting to this point—this macro is just a bit more complicated than the 2.x series (28 macros vs 10 macros). Without his help, I'm not sure I would've gotten here :).

-rob.