-2

I want if I select a text in a webpage that I can do a Google search in one shortcut click on my keyboard.

It must do this:

  • copy the selected text to clipboard
  • goto the address bar in the browser.
  • 1 - write https://www.google.com/search?q=
  • 2 - + write the selected text in the address bar
  • 3 - + write google parameters search?q=selected text + &num=100 + &lr=lang_de + &hl=de
  • and than together with 1+2+3 - do direct a google search in browsers like chrome/firefox/explorer/edge

the code must be written in autohotkey languages for windows 10.

the AHK code must be like:

; + = Shift
; # = Win (Windows logo key)
; ! = Alt
; ^ = Ctrl 


^s:: ; press ctrl+s to do a google search
send ^c ; copy the selected text to clipboard
text = %clipboard%
send https://www.google.com/search?q=%text%&num=100&lr=lang_de&hl=de
send {enter}
return

This code does not goes automatically to the address bar and then do a Google search.

I need a code that does do this automatically in one shortcut click

  • 1
    I've made some changes to correct your spelling mistakes, but you've rolled it back - I made the changes to make sure your question is clear. Not sure why you didn't accept those changes. – Dave Oct 11 '16 at 13:55
  • 1
    "I need a code that does do this automatically in one shortcut click" - I am going to issue a downvote, since you are asking us to provide you code, it is irrelevant in my eyes if you eventually figured out how to do it yourself and ended up answering your own question. – Ramhound Nov 4 '16 at 13:44
  • Ramhound, I am new here and need to learn how everything works. I did later figured it out by myself and did answer self my question so that other people can use this code. – arnoldburg Nov 5 '16 at 13:53
0

It's not clear what isn't working for you as your question lacks a lot of detail - I can only assume that Google Chrome doesn't execute.

send ^c 
text = %clipboard%
Run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe  https://www.google.com/search?q=%text%&num=100&lr=lang_de&hl=de
send {enter}
return
  • I haven't close your question? – Dave Oct 11 '16 at 14:18
0

This code works in all browsers, you can select any text in any website

Press F2 to do direct a Google search from the selected text. [us] [50 results]

Use this AHK script:

; ^ = Ctrl
; + = Shift
; ! = Alt
; # = Win (Windows logo key)
GroupAdd, Browser, ahk_class Chrome_WidgetWin_1 ; Chrome or Iron
GroupAdd, Browser, ahk_class IEFrame            ; Internet Explorer
GroupAdd, Browser, ahk_class MozillaWindowClass ; FireFox
GroupAdd, Browser, ahk_class ApplicationFrameWindow ; Edge

#If WinActive("ahk_group Browser")

f2:: ; press f2 for a google search
send ^c ;copy the selected text to clipboard memory
sleep 150
send ^t ; CTRL+t this will make a new tab + go to address bar  - use CTRL+L for the active tab + go to address bar
sleep 150
text1 = https://www.google.com/search?q=
text2 = %clipboard% ;selected text
text3 =  &lr=lang_us&hl=us&num=50 ; google parameters

clipboard=%text1%%text2%%text3%
sleep 150
send ^v ; paste the selected text 
sleep 250
send {enter}
clipboard=%text2%
return  
  • 1
    I don't think the text3 parameters are required. I can go to google.com/search?q=example and it'll execute my search no problem. I believe you can use those parameters to change the language or number of results though. – cascer1 Oct 17 '16 at 12:16
  • text3 parameters you will need - if you want to make more scripts for example f2::(United States-50results) and f3::(germany-100results) – arnoldburg Oct 17 '16 at 13:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.