#IfWinActive ahk_class CabinetWClass
+Enter:: ;open file with Paint/Notepad (open folder in new window)
#IfWinActive ahk_class ExploreWClass
+Enter::
#IfWinActive ahk_class Progman
+Enter::
#IfWinActive ahk_class WorkerW
+Enter::
WinGet, hWnd, ID, A
WinGetClass, vWinClass, % "ahk_id " hWnd
vPath := "", vIsDir := 0
if (vWinClass = "CabinetWClass") || (vWinClass = "ExploreWClass")
{
for oWin in ComObjCreate("Shell.Application").Windows
{
if (oWin.HWND = hWnd)
{
vIsDir := oWin.Document.FocusedItem.IsFolder
vPath := oWin.Document.FocusedItem.Path
break
}
}
oWin := ""
}
else if (vWinClass = "Progman") || (vWinClass = "WorkerW")
{
VarSetCapacity(hWnd, 4, 0)
;SWC_DESKTOP := 0x8 ;VT_BYREF := 0x4000 ;VT_I4 := 0x3 ;SWFO_NEEDDISPATCH := 0x1
oWin := ComObjCreate("Shell.Application").Windows.FindWindowSW(0, "", 8, ComObject(0x4003, &hWnd), 1)
vIsDir := oWin.Document.FocusedItem.IsFolder
vPath := oWin.Document.FocusedItem.Path
oWin := ""
}
if (vPath = "")
{
MsgBox, % "error: file not found"
return
}
else if !FileExist(vPath)
{
MsgBox, % "error: file not found:`r`n" vPath
return
}
else if vIsDir
{
Run, % Chr(34) vPath Chr(34)
return
}
FileGetSize, vSizeMB, % vPath, M
if (vSizeMB > 6)
{
MsgBox, % "error: file too big: " vSizeMB " MB"
return
}
SplitPath, vPath, vName, vDir, vExt, vNameNoExt, vDrive
if vExt in % "bmp,gif,jpe,jpeg,jpg,png"
Run, mspaint.exe "%vPath%"
else
Run, notepad.exe "%vPath%"
return
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter