Set variable with selected text and append to defined search URL

I want to take some of the tedium out of a specific search I am performing. I want to select text then hit the macro which will take the text and insert it into a url and then open a new Safari window and insert the URL and perform the search.

example URL:

I assume I need to use a variable to store the selected text. Can someone get me started on this or point me to a post that nails it.

1 Like


Take a look at the below macro I just posted.
It is set to use Google Chrome and Google Search, but it can easily be changed to Safari and whatever search engine you prefer.

@JMichaelTX has nailed this one with his ubermacro, but just to give you some building blocks for future problem solving...

You could do something like this:

Or something like this:

Thank you, this was just what I was looking for! One small thing: after pressing the hotkey, a "AppleScript Results" window pops up saying "The output of script "Unknown" is:" Do you know how to prevent this from popping up?

Are you sure you are using my macro? It does NOT contain any AppleScripts.

I'm using the macro "OPEN URL or Search Using Google Chrome", which I believe to be yours, and no other macro's are enabled. The only thing I modified is the SearchURL. I'm using Mojave 10.14.6.

So, here is how to solve problems like this:

  1. In the KM Editor Search box (top right), enter "script" to search for the word "script" in the name of Actions.
  2. The Actions that match this will have blue stripe color
  3. Click on the Execute Script option "display results in a window", and select "ignore results"

That's it!

1 Like

I tried the new macro you posted and it works like a charm! For other people who are interested in this time-saving jewel: have a look at @JMichaelTX's updated macro (1 December 2019)

Thank you!

1 Like