The usual method of [Select file > Right click > Open with > Drill down to your program] is cumbersome and time consuming.
Thus, this little script. Just select your image file and press the hotkey. The image will open in the editor you set in the script's ProgPath.
The script will notify with a message box if the selected item is not a valid image file, or report if it is actually a folder rather than a file.
I attempted to make it so that more than one image file could be selected and then opened all at once to no avail.
Perhaps someone with more AHK experience can expand on this. Otherwise works great as is for what I was attempting.
Code: Select all
ProgPath := "C:\Full\Path\To\Your\Image\Editing\Program.exe"
^F3::
SelectedItem := GetSelectedItemPath()
if (FileExist(SelectedItem) && !IsFolder(SelectedItem)) {
if (IsValidImageFile(SelectedItem)) {
Run, % ProgPath " """ SelectedItem """"
Soundbeep, 1900, 75
Soundbeep, 1900, 75
} else {
Soundbeep, 1200, 75
Soundbeep, 1000, 150
MsgBox, , , The selected file is NOT a valid Image File., 3
}
} else {
Soundbeep, 1000, 75
Soundbeep, 1000, 75
MsgBox, , , The selected item is a Folder`n ...NOT a File., 3
}
Return
;--------------------------
GetSelectedItemPath() {
Clipboard := ""
Send, ^c
ClipWait
Return Clipboard
}
IsValidImageFile(FilePath) {
ImageExtensions := ".bmp.jpg.jpeg.png.gif.tif.tiff"
FileExt := SubStr(FilePath, InStr(FilePath, ".",, -1))
Return InStr(ImageExtensions, FileExt)
}
IsFolder(FilePath) {
Return (SubStr(FileExist(FilePath), 1, 1) = "D")
}
Return
One issue I've noticed is it will treat some folders as images on my system, as I use a software called FolderIco to change the look of individual folders.
Apparently the script views some of them as images, although I haven't determined why yet. And as that condition is primarily intended to catch clumsy
key presses that generally aren't an issue anyhow, I'm not sure how hard I will look into it. The Soundbeeps are just simple audible notifications that
something after the hotkey is pressed is happening, and they can be removed if found annoying.