Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a completely noob when it comes to AutoHotkey scripts, the limit of my knoweldge is opening a folder with a key combination.

There's one Mac feature that I've always been envious of, the spacebar-to-open-a-file feature (I think it's called Preview). Is it possible to set up an AutoHotkey script to open a file with a certain program? Specifically, I'd like to be able to press ctrl+enter and open files with Picasa Photo Viewer (obviously this isn't quite as advanced as Preview, but most of what I want to preview are PSD files anyway).

The Photoviewer's exe is located here with a default install: C:\Program Files (x86)\Google\Picasa3\PicasaPhotoViewer.exe


EDIT: I've found this, but it doesn't fit my needs entirely. I need to be able to have a file selected in Windows Explorer and just press ctrl+enter to open the selected file.

Run, wordpad my.txt

share|improve this question
up vote 1 down vote accepted

AutoHotkey doesn't interface with Windows Explorer. However, we can use the clipboard to overcome this.

The script

    Backup := ClipboardAll
    Clipboard = 
    SendPlay, ^c
    ClipWait, 1
    Type := FileExist(Clipboard)
    If Type = A
        Run, "C:\Program Files (x86)\Google\Picasa3\PicasaPhotoViewer.exe" %Clipboard%
    Clipboard := Backup

Hot it works

  • ^Enter:: ... return specifies the hotkey, where ^ is Ctrl and Enter is Enter.

    If it's pressed, ... gets executed.

  • Backup := ClipboardAll backs up all data stored in the clipboard (All also includes non-text data like, e.g., screenshots).

  • Clipboard = clears the clipboard, so we can check when something gets copied to it.

  • SendPlay, ^c simulates pressing the key combination Ctrl + C to copy the current file to the clipboard.

    As a result, the variable Clipboard now hold the file's name.

  • ClipWait, 1 waits for up to one second for the clipboard to contain any data.

  • Type := FileExist(Clipboard) and If Type = A check if the clipboard's content points to an actual file.

  • Run, "C:\Program Files (x86)\Google\Picasa3\PicasaPhotoViewer.exe" %Clipboard% opens the selected file in Picasa.

  • Clipboard := Backup restores the inital clipboard data.

share|improve this answer
Doesn't seem to work, cursor flashes to loading for a split second, then nothing happens. Entering a similar command in to the command prompt does work, though, so obviously you can launch files with PhotoViewer in that method. – Rev Jul 13 '12 at 17:38
Still nothing. Tried it with Notepad instead and I'm getting an error "The filename, directory name, or volume label syntax is incorrect." – Rev Jul 13 '12 at 17:59
I'm just selecting one. – Rev Jul 13 '12 at 18:10
I get "MsgBox, %clipboard%" (probably because I copied that line of code). If I copy the image, then press ctrL+Enter I get the path of the file. Copying the file manually, then pressing ctrl+enter opens the file, so it appears to be an issue when copying the file. – Rev Jul 13 '12 at 18:39
Just getting a blank message box now. – Rev Jul 13 '12 at 18:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .