I'm currently using the code below to open valid file directories or URLs directly. The only thing that doesn't work so far is the Program Files (x86) directory.
For example, if I #Q for "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe, it only navigates to C:\Program Files. How do I improve the code to include (x86) directories?
Code: Select all
; Go to anything that is in the currently selected text: URLs, email addresses, Windows paths, or just "Google it" USING WIN+Q
$#Q::
;Tip("Clipping...") ;; include my mouse-tip library for this https://gist.github.com/2400547
clip := CopyToClipboard()
if (!clip) {
return
}
addr := ExtractAddress(clip)
if (!addr)
{
; Google it
;Tip("Searching for [" SubStr(clip, 1, 50) "] ...")
addr := "https://encrypted.google.com/search?q=" . clip
}
else {
; Go to it using system's default methods for the address
;Tip("Going to " Substr(addr, 1, 25) " ...")
}
Run %addr%
return
Code: Select all
ExtractAddress(str)
{
if (RegExMatch(str, "S)((http|https|ftp|mailto:)://[\S]+)", match))
return match1
if (RegExMatch(str, "S)(\w+@[\w.]+\.(com|net|org|gov|cc|edu|info))", match))
return "mailto:" . match1
if (RegExMatch(str, "S)(www\.\S+)", match))
return "http://" . match1
if (RegExMatch(str, "S)(\w+\.(com|net|org|gov|cc|edu|info))", match))
return "http://" . match1
if (RegExMatch(str, "S)([a-zA-Z]:[\\/][\\/\-_.,\d\w\s]+)", match))
return match1
if (RegExMatch(str, "S)(\\\\[\w\-]+\\.+)", match))
return match1
return ""
}