Forum moved here!

Home / Google-search a word/phrase with right-click

Tim_Marshall

People often encounter difficult words, esp in:

  • textbooks (including those people need to read to see if they’re getting the right dental/medical treatment)
  • old books
    It would be incredibly useful to me to be able to right-click a word, and tap one button to do a google search on that word.

PS I’ve been using Sumatra for awhile now and I love how light-weight it is.

SumatraPeter

Ideally speaking the search engine would be configurable, for those who’d rather not use Google. That way we can specify something like https://search-engine.com/search?q=%s and Sumatra would replace %s with proper encoded text before invoking the default browser.

than

Also requesting that feature.

Documents often need further explaining for which nothing is easier than highlight and right mouse search.

SumatraPeter

Relevant list of GitHub issues can be found below (so more duplicates aren’t created).

GitHubRulesOK

Based on comments and right button search request by Tim_Marshall + @ than

I thought some of you might like to test out the following simple AHK code
just save it as say SEARCH.AHK

[UPDATE] there is an alternative method using Windows scripting (no need for AutoHotKey) in thread [Advanced Tips] Pass selection to another app e.g. Web Search

; Web lookup for any text including SumatraPDF
; Highlight some text then press Alt & Right Button

!RButton::

; Save and clear clipboard
StoredClipboard := ClipboardAll
Clipboard:= ""

; Send copy command (^c) to collect selected text
SendInput, ^c
; Wait a mo
ClipWait, 1

Run https://www.startpage.com/do/dsearch?query=%Clipboard%

; Reset Clipboard
Clipboard := StoredClipboard
Return

Save the above version or right click here to download a similar version by Nod5 as described later you can replace the startpage line with your preferred search engine e.g.

Run http://www.google.com/search?q=%Clipboard%

you can even change browser

Run "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" "http://www.google.com/search?q=%Clipboard%"

NOTE:- that’s all on one line and in this case the search needs to be enclosed in quotes

you can also try

Run https://en.wikipedia.org/wiki/%Clipboard%

or a translator or dictionary or … let your imagination take you there

If you don’t have latest portable AutoHotKey Zip
Download from https://autohotkey.com/download/ahk.zip

save zip file currently (April 2014) its AutoHotkey_1.1.28.02.zip
extract its contents and drop SEARCH.AHK onto
AutoHotkeyU32.exe

Tested with XP up to Win8.1 Pro x64 using several browsers etc.
(can’t test on Win 10 at present) if all is well there will be a green H icon in the Icon tray

If you want a second choice such as translate you can add to the end of the above text (after the return) this section

; Web translate for any text including from within SumatraPDF
; Highlight some text then press AltGR Key (that's the alt key to right of spacebar)

 *RAlt::

; Save and clear clipboard
StoredClipboard := ClipboardAll
Clipboard:= ""

; Send copy command (^c) to collect selected text
SendInput, ^c
; Wait a mo
ClipWait, 1

Run https://translate.google.com/?hl=en&q=%Clipboard%

; Reset Clipboard
Clipboard := StoredClipboard
Return
SumatraPeter

How many such workarounds does one keep accumulating over time as Band-Aids to missing functionality in a program? Anyway, as I’ve said earlier you are free to use AHK or anything else as stopgap measures and so are others, and my personal preference has no bearing on it.

BTW you’ve used StoreClipboard once and then StoredClipboard.

Also, a “StoredClipboard =” at the end might be useful in order to free up memory in case the clipboard’s original content was quite large.

GitHubRulesOK

Thanks Peter,

Think of it as an extension (Band-Aid) to windows outside of SumatraPDF

Well spotted. I have changed code above so both read as StoredClipboard , not so logical at start but hopefully indicative, the intent was to preserve users current clipboard contents so it can be restored (no matter how big it was)

[UPDATE]
Also have expanded examples again
what’s everyone’s favourite choice of look-up?

SumatraPeter

I prefer DuckDuckGo.

than

Favourite look-up has to be Google for me

Amazing1

I downloaded the .zip file, unpacked it and it looks like this
in my folder-
Compiler
AutoHotkey.chm
AutoHotkeyA32.exe
AutoHotkeyU32.exe
AutoHotkeyU64.exe
Installer.ahk
license.txt
Template.ahk
WindowSpy.ahk

Which one would be the SEARCH.AHK ?
Thanks

SumatraPeter

Read the thread carefully:

vedranvuk

Hi,

would it be possible to add a context menu search for selected text where optionally a user defined search engine could be set in advanced options?

Thanks,
Vedran

SumatraPeter

Requested multiple times, and rejected at least once:



Edit: All consolidated under the following now:

enviroby

Feature Request: Select, right-click, paste to Google

Would be very handy.

SumatraPeter

For now, you can check above or here for AutoHotkey scripts to implement this.

AiDen

Maybe add a shortcut which allows users to search the selected text online if possible, just like the ones that are built in edge and chrome.

AiDen

A shortcut on the right-click menu can be better :smile:

xak_ahmad

can anyone explain in simple way how to get this this working? I am new to this. Thanks

GitHubRulesOK

@xak_ahmad

It is probably easier to use the method shown in the earlier link [Advanced Tips] Pass selection to another app e.g. Web Search it is less automatic but potentially simpler as it uses one windows script file combined with an edit to the Advanced settings file