Autohotkey 自动热键打开当前应用程序或进程的文件夹

Autohotkey 自动热键打开当前应用程序或进程的文件夹,autohotkey,Autohotkey,在此代码中,没有打开当前应用程序文件夹,因为FilePath变量包含exe文件名 F11:: PID = 0 WinGet, hWnd,, A DllCall("GetWindowThreadProcessId", "UInt", hWnd, "UInt *", PID) hProcess := DllCall("OpenProcess", "UInt", 0x400 | 0x10, "Int", False , "UInt"

在此代码中,没有打开当前应用程序文件夹,因为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% 
提前感谢您的帮助

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


@dcaro JFYI您可以通过单击答案附近的复选标记来接受答案。有关接受答案如何工作的更多信息,请参见此。另外,当你接受一个答案时,如果你也通过点击帖子附近的向上箭头来投票,那就太好了。这根本不是强制性的,但它是普通的、合理的和推荐的。虽然您只能接受一个答案,但您可以根据自己认为有用的答案(包括已接受的答案)进行投票。@user3419297 JFYI当您认为某个问题有用且回答正确时,您也可以对该问题进行投票。
F11::
WinGet, path, ProcessPath, A
Run, % "explorer.exe /select," . path
return