Skip to content

Instantly share code, notes, and snippets.

@thefloodshark
Created April 2, 2018 09:59
Show Gist options
  • Save thefloodshark/ac28ec45bffb7b413d1c4b082679d10f to your computer and use it in GitHub Desktop.
Save thefloodshark/ac28ec45bffb7b413d1c4b082679d10f to your computer and use it in GitHub Desktop.
Highlight Google Search (CTRL+G)
~#!x::Suspend
SendMode Input
RegRead, OutputVar, HKEY_CLASSES_ROOT, http\shell\open\command
StringReplace, OutputVar, OutputVar,"
SplitPath, OutputVar,,OutDir,,OutNameNoExt, OutDrive
browser=%OutDir%\%OutNameNoExt%.exe
^g::
{
BlockInput, on
prevClipboard = %clipboard%
clipboard =
Send, ^c
BlockInput, off
ClipWait, 2
if ErrorLevel = 0
{
searchQuery=%clipboard%
GoSub, GoogleSearch
}
clipboard = %prevClipboard%
return
}
GoogleSearch:
StringReplace, searchQuery, searchQuery, `r`n, %A_Space%, All
Loop
{
noExtraSpaces=1
StringLeft, leftMost, searchQuery, 1
IfInString, leftMost, %A_Space%
{
StringTrimLeft, searchQuery, searchQuery, 1
noExtraSpaces=0
}
StringRight, rightMost, searchQuery, 1
IfInString, rightMost, %A_Space%
{
StringTrimRight, searchQuery, searchQuery, 1
noExtraSpaces=0
}
If (noExtraSpaces=1)
break
}
StringReplace, searchQuery, searchQuery, \, `%5C, All
StringReplace, searchQuery, searchQuery, %A_Space%, +, All
StringReplace, searchQuery, searchQuery, `%, `%25, All
IfInString, searchQuery, .
{
IfInString, searchQuery, +
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe http://www.google.com/search?hl=en&q=%searchQuery%
else
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe %searchQuery%
}
else
Run, C:\Program Files (x86)\Google\Chrome\Application\chrome.exe http://www.google.com/search?hl=en&q=%searchQuery%
return
ScrollLock::Suspend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment