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.

  • I like this one a lot... wonder if you could do the same thing with Freetranslation.com. I'd like to see this as a proper feature in Studio, so just select some text and get a look up that you could use immediately if appropriate without leaving the editor.
  • Ok, I didn't even know about the existence of Freetranslation.com! By modifying the Google script only with the website address, I can get the webpage to open and the cursor to be placed in the search field, but I can't seem to paste the clipboard text onto the field. I've tried adding long wait times but I haven't found the right one yet.

    ;Freetranslation.com lookup
    !f::
    OldClipboard:= Clipboard
    Clipboard:= ""
    Send, ^c ;copies selected text
    ClipWait
    Run www.freetranslation.com/search
    Sleep 1000
    Send ^v
    Clipboard:= OldClipboard
    Return

    I think this has a lot of potential, because the suggested translation could even be copied from the website and pasted back into Studio.

    Unfortunately, I have to stop playing with AutoHotkey now and get back to work. : )

    But please share if you get it to work.
  • Here's an updated version of the FreeTranslation script that is working for me. After the initial language setup, the script should open a new page with the same settings every time it's run.

    Alt+F to launch the script after selecting the desired text

    ;Freetranslation.com lookup
    !f::
    Sleep 200
    Send, ^c
    ClipWait
    Run www.freetranslation.com/search
    Sleep 2000
    Send ^v
    Send, +{Tab}
    Send, {Enter}
    Return
  • 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.

  • But perhaps also note that the weblook up tool on the appstore can do this already so if you wanted to have this ability to look things up in websites and have the result in Studio then it might be better for your purposes?

    multifarious.filkin.com/.../

    There is also another app on the appstore that can use the results as autosuggest so this might be even more useful!

    appstore.sdl.com/.../
  • Hi Ivan,

    Ivan: Nora's shortcut is ALT+F, not ALT+G.

    Also, in my machine I needed to wait 4 seconds before pasting the text to make work. This works for me:

    […]

    Run www.freetranslation.com/search

    Sleep 4000

    […]

    … Jesús Prieto …

  • Unknown said:
    But perhaps also note that the weblook up tool on the appstore can do this already so if you wanted to have this ability to look things up in websites and have the result in Studio then it might be better for your purposes?

    multifarious.filkin.com/.../

    There is also another app on the appstore that can use the results as autosuggest so this might be even more useful!

    appstore.sdl.com/.../
     

    This is absolutely true and I was thinking about it yesterday, although I've stopped using Web Lookup because things were just too crowded with the new 2017 features and opening Web Lookup results on a second monitor always seemed awkward. With this script I can have the search run on a second monitor without interfering with Studio. Maybe that would be a variation or option that we could suggest for the Web Lookup app: the ability to run outside of Studio. But wait... I think that's what IntelliWebSearch does already. : )

    Anyway, it's nice to have as many tools as possible at our disposal!

  • Unknown said:
    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 Ivan,

    Paul has posted an alternative script but just to follow up, I think I see why it's not working for you (and for Paul). When I pasted the script on this forum, part of it got converted into a link, which is not what you need. This is my actual script:

    ;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

     

    As you can see, the part of the variable, called %Clipboard%, where the contents of the clipboard are pasted into the search field, was not showing in the original post.

    Hope it works for you now!

    Best,

  • Unknown said:

    Hi Ivan,

    Ivan: Nora's shortcut is ALT+F, not ALT+G.

    Also, in my machine I needed to wait 4 seconds before pasting the text to make work. This works for me:

    […]

    Run www.freetranslation.com/search

    Sleep 4000

    […]

    … Jesús Prieto …

     

    Yes, Alt+F for freetranslation.com and Alt+G for Google. And I also find that increasing the wait times usually solves many of my problems in AHK. : )