Create a gist now

Instantly share code, notes, and snippets.

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

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