I have managed to create the script in a different way that I first thought was possible.
Here is the script if anyone is interested (hot to use is after script):
Code: Select all
;;;;;;;;;;;;;;;;;;;;
; Search Functions ;
;;;;;;;;;;;;;;;;;;;;
; Not my function, taken from somewhere else on the internet, can't credit author since I forgot where I got it from :(
uriEncode(str) {
f = %A_FormatInteger%
SetFormat, Integer, Hex
If RegExMatch(str, "^\w+:/{0,2}", pr)
StringTrimLeft, str, str, StrLen(pr)
StringReplace, str, str, `%, `%25, All
Loop
If RegExMatch(str, "i)[^\w\.~%/:]", char)
StringReplace, str, str, %char%, % "%" . SubStr(Asc(char),3), All
Else Break
SetFormat, Integer, %f%
Return, pr . str
}
; Search Google
::``g::
Input, UserInput, T5 L25 C, {enter}.{esc}{tab}
textToInsert := uriEncode(UserInput)
googleUrl := "https://www.google.com/search?num=50&safe=off&site=&source=hp&q=REPLACEME&btnG=Search&oq=&gs_l="
safeUrl := StrReplace(googleUrl, "REPLACEME", textToInsert)
Run %safeUrl%
return
; Search Youtube
::``y::
Input, UserInput, T5 L25 C, {enter}.{esc}{tab}
textToInsert := uriEncode(UserInput)
youtubeUrl := "https://www.youtube.com/results?search_query=REPLACEME"
safeUrl := StrReplace(youtubeUrl, "REPLACEME", textToInsert)
Run %safeUrl%
return
; Search Autohotkey
::``a::
Input, UserInput, T5 L25 C, {enter}.{esc}{tab}
textToInsert := uriEncode(UserInput)
youtubeUrl := "https://www.google.com/search?num=50&safe=off&site=&source=hp&q=autohotkey%20REPLACEME&btnG=Search&oq=&gs_l="
safeUrl := StrReplace(youtubeUrl, "REPLACEME", textToInsert)
Run %safeUrl%
return
How to use:
If you want to search google for black banana, you type the following on your keyboard (had to pause my script so I can type this
):
Code: Select all
`g{space}black{space}banana{enter}
It's that easy, and then a google search will open in your default browser. To search on youtube, you replace the g with a y and it just works. No GUI, the way I want it