How to query a specific website with the MacOS selection

I have been using Alfred for a huge amount of time for this, but I want to try to make it work in Keyboard Maestro.

What I want my macro to do is query the current selected content (not the clipboard content) against a specific website.

In other words, I select a word on a website with my mouse/trackpad (for example: "fit"), hit a keyboard shortcut and the website wordreference.com opens with the url https://www.wordreference.com/enfr/fit.

I looked in the wiki and only saw how to search the Web. I also saw a 2015 post about how to set variable to currently selected text but it requires to copy the selection and do not want that (mostly because with Alfred I have a way of doing it without having to copy the selected text to the clipboard. Plus, as I know I would these macros at least 50 times a day, I want to spare as many steps as possible).

Reply to my question :

Uploading: Screenshot_2019-09-06_14.24.59.png...

See if this will suit your needs.

WordReference Search Macro

WordReference Search.kmmacros (23 KB)

KC

1 Like

Thanks for sharing. Your solution works, but can be improved by:

  • Eliminate use of Named Clipboard -- Use Local Variable
  • Percent Encode selected text

Generally speaking it is best to not use Named Clipboards unless you need to use rich text or images.
Percent Encode (Filter action) is needed to encode any special characters in the selected text.

MACRO:   WordReference Search Ver 2

**Requires: KM 8.2.4+   macOS 10.11 (El Capitan)+**
(Macro was written & tested using KM 9.0+ on macOS 10.14.5 (Mojave))

#### DOWNLOAD Macro File:
<a class="attachment" href="/uploads/default/original/3X/b/8/b8ce35471c803673d496df05105657532a2e2613.kmmacros">WordReference Search Ver 2.kmmacros</a>
**Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.**


---

### ReleaseNotes

Version: 2.0	by @JMichaelTX
	1.	Simplify
	2.	Elimiate use of Named Clipboard -- Use Local Variable
	3.	Percent Encode selected text
`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

Author:  KC
Macro Name:  WordReference
Version: 1.01
First Created: 2019-09-06
Last Modified: 2019-09-06


Change log:
Version 1.01:  2019-09-06 - New

In KM Preferences, create a Clipboard called: text (or any other Clipboard name.  Just make sure you change the Clipboard selections where the text Clipboard appears in the Macro)

Select the word and use the hotkey to launch the WordReference Search. The Entry variabile and clipboard will clear after use.

`~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

<img src="/uploads/default/original/3X/4/a/4ab0fd81a5091c543d1e6282cd32f267ac733802.png" width="531" height="1106">
2 Likes

WOW.

Thank you @JMichaelTX and @kcwhat it is EXACTLY what I was looking for !

@JMichaelTX There is a little typo (variabile) in you post :shushing_face: More seriously, I would have never been able to make my macro work as I didn't know about the filter action.

That typo is actually from the Comments Action created by @kcwhat.

Select the word and use the hotkey to launch the WordReference Search. The Entry variabile and clipboard will clear after use.

Yep, the KM Filter Action is really like a multi-purpose function of mostly unrelated actions.
IMO, the term "Filter" is misleading, as many of its functions are transformations, not filters (as in removing items from a list).

In fact, the first line from the KM Wiki spells this out:

The Filter action is extremely powerful for ==editing== the contents of a variable, clipboard or file.

:face_with_raised_eyebrow::unamused:

I guess that's what I get for rushing to help someone in need. Spellcheck didn't save me but I surely didn't expect to get thrown CLEAN under the bus... Wow!

Does anyone have a KM macro to remove tire tracks off of my back? I'm in severe need.

Thanks so much.

@kcwhat, I'm not sure what you are complaining about. If it is about the typo, then I'd just forget about it and move on. I never point out typos in a forum like this, but when I was falsely accused of a typo, I simply pointed to the source, no busses involved. If you'll note I did not say anything about the typo in my response to your posting. IAC everyone makes typos, and I'm not going to sweat it when I do.

Having said that, take a look at this cool macro just posted that makes spell checking very easy:
MACRO: Spellcheck from word underlined in red without using mouse

@kcwhat

All my apologies if my comment about a typo hurt you.
My intention was only to help the author to correct it.

Gentlemen, I was actually making light of the situation. It's no big deal and I shouldn't have commented on it. Therefore, no apology needed. I learned my dry humor doesn't translate to forum conversation. Like JMTX said, forget about it, move on and make more KM Macros.

2 Likes

Yep. Although we are often funny in person, humor rarely translates well in forums where the only cue we have is dry text. In addition, we have an international membership here, and even regional differences within a country, can make proper interpreting of text difficult, especially humor.

But I'm glad to know that you were just kidding! :smile:

Carry on.

1 Like