正常.ahk文件回車即運行,想要編輯必須右鍵菜單,選擇E,或者鼠標單擊[編輯]。
更好的方式Shift+Enter作爲熱鍵來進行編輯代碼。
#IfWinActive ahk_class TTOTAL_CMD
+Enter::
#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 = "TTOTAL_CMD")
{
MsgBox "Tc"
}
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
FileGetSize, vSizeMB, % vPath, M
if (vExt = "lnk")
FileGetShortcut, % vPath, vPath
if vExt in ,bat,ahk,reg,vbs,txt,htm,html,mht,cpp,h,m3u,mpcpl,url,clp,ini,cfg,csv,srt,log
Run, "notepad.exe" "%vPath%" ;這裏改成你常用的文本編輯器
else if vExt in bmp,gif,jpe,jpeg,jpg,png
Run, "mspaint.exe" "%vPath%"
Return