Quick Google look-up of selected text

Press Alt+G after selecting the text

;Google lookup
!g::
OldClipboard:= Clipboard
Clipboard:= ""
Send, ^c ;copies selected text
ClipWait
Run http://www.google.com/search?q=%Clipboard%
Sleep 200
Clipboard:= OldClipboard
Return

 

Edit: Part of the script had been converted to a link and was not showing properly. I've now edited this.

Parents
  • Hi Nora,

    I'm very interested this script. I frequently use google to search words during translation. I never used AHK before. It seems very powerful. I just tried this script. When I press Alt+G, only the google search window pops up. The selected texts are not pasted into the search box. Would you please kindly advise what to do at your convenience? Thanks,

    Regards,
    Ivan
  • Hi guys,

    This doesn't work for me either now I test it, but there is a script here in the AHK site that does work:

    ;------------------------------------------------------------------------------
    ;Google lookup
    ;------------------------------------------------------------------------------
    ^!g::
    prevClipboard := ClipboardAll
    SendInput, ^c
    ClipWait, 1
    if !(ErrorLevel) {
    Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "(^\s+|\s+$)")
    If SubStr(ClipBoard,1,7)="http://"
    Run, % Clipboard
    else
    Run, % "www.google.com/search Clipboard
    }
    Clipboard := prevClipboard
    return

    To make it work I have to press Ctrl+c to copy the text selected to my clipboard and then press Ctrl+Alt+g.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

Reply
  • Hi guys,

    This doesn't work for me either now I test it, but there is a script here in the AHK site that does work:

    ;------------------------------------------------------------------------------
    ;Google lookup
    ;------------------------------------------------------------------------------
    ^!g::
    prevClipboard := ClipboardAll
    SendInput, ^c
    ClipWait, 1
    if !(ErrorLevel) {
    Clipboard := RegExReplace(RegExReplace(Clipboard, "\r?\n"," "), "(^\s+|\s+$)")
    If SubStr(ClipBoard,1,7)="http://"
    Run, % Clipboard
    else
    Run, % "www.google.com/search Clipboard
    }
    Clipboard := prevClipboard
    return

    To make it work I have to press Ctrl+c to copy the text selected to my clipboard and then press Ctrl+Alt+g.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

Children