Skip to content

Instantly share code, notes, and snippets.

@NelsonMinar
Created December 11, 2010 17:15
Show Gist options
  • Save NelsonMinar/737478 to your computer and use it in GitHub Desktop.
Save NelsonMinar/737478 to your computer and use it in GitHub Desktop.
AutoHotkey script to make CapsLock open URLs and search Google
; AutoHotkey script to make CapsLock open URLs and search Google with Clipboard contents.
; By Nelson Minar <nelson@monkey.org> Inspired by code at http://www.autohotkey.com/forum/topic14656.html
CapsLock::
url := RegExReplace(Clipboard, "^\s+|\s+$") ; Trim whitespace
if RegExMatch(url, "^(http|ftp|telnet)") {
; Do nothing if it already looks like a URL
} else {
; Escape the query string. Could escape more, but this seems sufficient for Chrome
StringReplace, url, url, `%, `%25, All
StringReplace, url, url, &, `%26, All
StringReplace, url, url, +, `%2B, All
url := "http://www.google.com/search?&q=" . url
}
Run %url%
return
@endolith
Copy link

Looks similar to mine: https://gist.github.com/823381#L73

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment