1
votes

I want do a google search in adress bar from the active browser that i use, On my windows 10 system.

The autohotkey (AHK) macro script must do this:

  • copy the selected text to clipboard memory
  • goto the adress bar
  • a - put the text https://www.google.com/search?q=
  • b - put the clipboard memory text
  • c - put the google parameter text &lr=lang_us&hl=us&num=50

a+b+c

And then if i click F2 it must can do, direct a google search with parameters

I need a command that can goto the adress bar in browsers like (google chrome) or other browsers (the active one)

This script code can not do that. it does not go to the adress bar

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

f2:: ; press f2 for a google search
send ^c 
send https://www.google.com/search?q=%clipboard%&lr=lang_us&hl=us&num=50
send {enter}
return  
1
Ctrl+L is the shortcut that works for both Firefox and Chrome if I recall correctly. Doesn't really warrant a full answer. - Elliot DeNolf
F6 does it too. - user3419297
CTRL+L this is what i want, i wil only need to insert a line into my code **SEND ^l ; CTRL+L **- thanks - arnoldburg
Fair enough, I posted a better script that uses your technique, but it's likely much than what ever you have come up thus far. - errorseven

1 Answers

1
votes

Try:

GroupAdd, Browser, ahk_class Chrome_WidgetWin_1 ; Chrome
GroupAdd, Browser, ahk_class IEFrame            ; Internet Explorer
GroupAdd, Browser, ahk_class MozillaWindowClass ; FireFox

#If WinActive("ahk_group Browser")

    F2::
        commands := ["{Ctrl Down}cl", "v{Ctrl Up}{enter}"]
        clipPrev := clipboard
        sleep 10
        for e, v in commands {
        SendInput % v
        sleep 10
        clipboard := A_Index == 1 
            ? format("https://www.google.com/search?q={}&lr=lang_us&hl=us&num=50"
            , clipboard)
            : clipPrev                           
        }
    return