Created
May 8, 2020 14:38
-
-
Save emisjerry/62b30565a94ec5fceed061598b06c15f to your computer and use it in GitHub Desktop.
AutoHotkey for Explorer hotkey extensions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#SingleInstance Force | |
;;用EmEditor編輯 | |
#IfWinActive ahk_class CabinetWClass | |
F4:: | |
;;sendInput {RButton}{1} | |
doActionInCurrentPath("EDIT") | |
return | |
;;重新命名 | |
`:: | |
doActionInCurrentPath("PATH") | |
return | |
#IfWinActive | |
;;先複製目錄,再複製路徑 | |
doActionInCurrentPath(sAction) { | |
WinGetClass, winClass, % "ahk_id" . hWnd := WinExist("A") | |
if !(winClass ~="Progman|WorkerW|(Cabinet|Explore)WClass") | |
Return | |
if (winClass ~= "Progman|WorkerW") | |
Return A_Desktop | |
;; 取得當前目錄 | |
oWindows := ComObjCreate("Shell.Application").Windows | |
for window in oWindows { | |
if (hWnd = window.HWND && sDir := window.Document.Folder.Self.Path) | |
break | |
} | |
;;Clipboard = %sDir% | |
;;ClipWait | |
;;msgbox folder=%Clipboard% | |
sFilePaths := "" | |
For SelectedItem In Window.Document.SelectedItems { | |
sPath := SelectedItem.Path | |
if (sAction = "PATH") { | |
sFilePaths := sFilePaths . sPath . " " | |
} else { | |
;msgbox EDIT=%sPath% | |
runByPath(sPath) | |
} | |
;MsgBox file=%sFilePaths% | |
} | |
if (sAction = "PATH") { | |
Clipboard = %sFilePaths% | |
ClipWait | |
} | |
;msgbox clip=%sFilePaths% | |
Return sPath | |
} | |
runByPath(sPath) { | |
iType := iOther | |
iPos := InStr(sPath, ".") | |
sExt := Substr(sPath, iPos+1, 255) | |
StringUpper sExt, sExt | |
;msgBox ext=%sExt% | |
if (sExt = "MD") { | |
run d:\util\code.bat "%sPath%" | |
} else if (sExt = "JPG" || sExt = "PNG" || sExt = "GIF") { | |
run mspaint "%sPath%" | |
} else { | |
run c:\util\EmEditor\EmEditor "%sPath%" | |
} | |
return "" | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment