This is great!
An important question;
Maybe anyone would be able to make it search for highlighted text? Meaning that you would not have to copy it, simply select/highlight it with your cursor.
I tweaked it a bit to be used with Win+W (luckily it overrides the Windows 10 shortcut)
I also added Win+Shift+W for searching with DuckDuckGo
Code: Select all
;reference https://www.autohotkey.com/boards/viewtopic.php?t=93891 a0l0e0x000
;Google
#w:: ; change to preferred hotkey
clip := clipboard
send, ^c
url := "https://www.google.com/search?q="
is_it_an_url := SubStr(clipboard, 1 , 8)
if (is_it_an_url = "https://") { ; if it starts with "https://" go to, rather than search in google search
run, %clipboard%
}
else { ;search using google search
joined_url = %url%%clipboard%
run, %joined_url%
}
clipboard := clip ;put the last copied thing back in the clipboard
return
;DuckDuckGo
#+w:: ; change to preferred hotkey
clip := clipboard
send, ^c
url := "https://duckduckgo.com/?q="
is_it_an_url := SubStr(clipboard, 1 , 8)
if (is_it_an_url = "https://") { ; if it starts with "https://" go to, rather than search in google search
run, %clipboard%
}
else { ;search using google search
joined_url = %url%%clipboard%
run, %joined_url%
}
clipboard := clip ;put the last copied thing back in the clipboard
return
[Mod edit: Replaced quote tags with [code][/code] tags.]