Windows – Google Desktop’s Ctrl,Ctrl feature on windows

browsergoogle-chromegoogle-desktop-searchkeyboard shortcutswindows

One thing I like about Google Desktop is you can configure it so that when you press Ctrl,Ctrl, it will bring up a dialog that looks like this:

Input box widget

The dialog will have focus and I can type in there, press enter, and then it will open a new tab in my default browser using the contents of the text box.

For instance; this allows me to type
Ctrl,Ctrl, foo, Enter
and it will open up this url: https://www.google.com/#q=foo

Is there a way to do this in Windows?
Failing that, is there a tool that will work like this?

Best Answer

It's possible to do this with a script for AutoHotkey (Windows automation software). Just open notepad, paste the code below and save it with the .ahk file extension. I could only test it on Windows 7 though. But it opens the search URL on a new tab as expected. The search dialog box looks like this:

this

global MySearch
Gui, Margin, 9, 10
Gui, Font, s12
Gui, Add, Edit, vMySearch w400 -WantReturn
Gui, Font, c999999 s7
Gui, Add, Text, Y+3, Press <ctrl> twice to hide/show.

GuiEscape: 
    Gui, Hide

#ifWinActive Google Search 
NumpadEnter::
Enter::
    submitSearch()
    return
#IfWinActive

Ctrl::
    KeyWait, Ctrl
    KeyWait, Ctrl, D, T0.12
    if ErrorLevel = 0 
    {
        if WinActive("Google Search")
            Gui, Hide
        else
            Gui, Show,, Google Search
    }
    return

submitSearch(){
    Gui, Submit
    searchURL := "https://www.google.com/#q=" . urlEncode(MySearch) 
    Run, %searchURL%
    GuiControl,, MySearch
}

urlEncode(url){
    VarSetCapacity(Var,StrPut(url,"UTF-8"),0),StrPut(url,&Var,"UTF-8")
    While Code:=NumGet(Var,A_Index-1,"UChar")
    Res.=(Chr:=Chr(Code))~="[0-9A-Za-z]"?Chr:Format("%{:02X}",Code)
    return,Res  
}
Related Question