Copy text then paste it surrounded by quotation marks for Google search

I'm new to KM and tried searching the archives but did not find a similar macro. When I highlight text, I want to press a trigger that will (1) copy the text, (2) paste the text into the Chrome URL bar, with quotation marks around the text, then (3) hit enter to execute the search. For example, if I'm reading an article on the web about John Smith, I'll use the mouse to select the phrase "John Smith" in the article, press the function key (say, for example, F1), then my Chrome window will be activated with the Google search results for "John Smith" (with quotation marks around it).

The macro does not have to do all of those steps, but the more time-saving I can make it, the better. Thanks!

Here you go!

"Google".kmmacros (20.7 KB)


Thank you, nousneil! That's fantastic. Really appreciate your time.

1 Like

I would never want to compete with grandmaster noisneil :slight_smile: but I think there is an even faster way to trigger this macro.

This is the trigger. Use "This device key" with or without a modifier. This triggers the macro directly after text selection "John Smith".

1 Like

You might want to filter your Cmd-click-release triggers -- for example, what does the above do if you are Cmd-clicking to select non-contiguous files in the Finder or an "Open" dialog?

Of course, if you don't use Cmd-click for anything else you'll be fine!

That's a good question Nige_S. I had to try this first too. if I Cmd-clicking to select non-contiguous text, it copies the text to the same clipboard.

And yes the files are also copied.

I like the idea! As @Nige_S says, it might not be the best key combo, as ⌘-click opens a link in a new tab in many browsers. Conflict with Finder etc aren't an issue if you put the macro in an app-specific group.

Just for fun, here's a version that only performs the search if something was copied. If you ⌘-click without highlighting, it does whatever ⌘-click usually does.

"Google".kmmacros (29.4 KB)


Oh, that's very nice, noisneil! I'm going to adopt that right away.

What I don't understand. I reply to a particular post at a time, but it doesn't show up.

Sorry, I don't follow. What do you mean?

I mean, when you address me, it looks like this.

But not vice versa.

Yeah sometimes it's hard to know whether the forum has recognised it as a direct reply. For that reason, I sometimes @ people as well to make sure they get notified.

Ah, ok, then it's not just me....
Funny that it shows that correctly when I write, but no longer when I post.


That wasn't really my concern. It's more that you are espousing a wide-ranging change to a "standard" action. You can Cmd-click in the Finder to also select a file that isn't "next to" the currently selected one(s), Cmd-click on the Photoshop "New Channel" icon makes a new spot channel, in Visual Studio it takes you to a class/function definition, etc.

None of that may matter to you, but IMO it's worth noting when it's suggested to other people. @noisneil's tweak is a nice addition, and restricting the macro to Chrome- (or browser-)only (which seems to be OP's requirement) will also limit the conflicts -- given that, I'm probably worrying unduly!

Mmm, that was just an example to show this trigger, not a suggestion to use a particular modifier.

1 Like

Since you need the mouse to copy the text, this would be an ideal macro to trigger with Popclip