Noah Coad
Open Clipboard Contents Hotkey



I find it particularly useful to be able to copy a file, folder, URL, or search term to the clipboard and then with one hotkey, open it up.  Here is the script I use with AutoHotkey to assign Win+O to open whatever’s in the clipboard.

First it checks to see if the clipboard contains a file, folder, or program that exists on disk.  If not, is it appear to be a URL?  And if not, just Google the clipboard contents.

; Execute the contents of the clipboard, Win+O
#o::
  contents = %clipboard%
  StringSplit, SplitArray, contents, `n
  Loop, %SplitArray0%
  {
    _line := SplitArray%a_index%
    
    ; First attempt a shell execute
    Run, %_line%,, UseErrorLevel

    ; If that didn't work, try something else
    if (ErrorLevel = "ERROR")
    {
      ; Does the clipboard contain a URL?
      FoundPos := RegExMatch(_line, "A)\w[^\s]*\.(?:com|co|uk|gov|edu|tv|net|org|tel|me|us|mobi|es)(?:\z|/.*)\z")
      if FoundPos 
        Run "%UserProfile%\AppData\Local\Google\Chrome\Application\chrome.exe" %_line%
      else 
        Run http://google.com/search?q=%_line%
    }
  }
return

It is also designed to open multiple items if separated by a carriage return, for example:

http://coad.net
http://facebook.com
http://noahcoad.com
  1. noahcoad posted this
Blog comments powered by Disqus