Autohotkey打开当前应用程序或进程的文件夹

时间:2016-04-19 18:23:20

标签: autohotkey

在此代码中没有打开当前应用程序文件夹,因为FilePath变量包含exe文件名

F11::
PID = 0
WinGet, hWnd,, A
DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt *", PID)
hProcess := DllCall("OpenProcess",  "UInt", 0x400 | 0x10, "Int", False
                                 ,  "UInt", PID)
PathLength = 260*2
VarSetCapacity(FilePath, PathLength, 0)
DllCall("Psapi.dll\GetModuleFileNameExW", "UInt", hProcess, "Int", 0, "Str", FilePath, "UInt", PathLength)

DllCall("CloseHandle", "UInt", hProcess)

Run, Explorer %FilePath% 

提前感谢您的任何帮助。

1 个答案:

答案 0 :(得分:2)

F11::
WinGet, path, ProcessPath, A
SplitPath, path, name, dir
Run, explorer.exe %dir%
return

或:

F11::
WinGet, path, ProcessPath, A
Run, % "explorer.exe /select," . path
return