
我想獲取活動文件的路徑。
活動文件路徑: C:\Users\e\Desktop\1w.jpg"
自動熱鍵結果: C:\Windows\System32\dllhost.exe
代碼:
q::
WinGet, Path, ProcessPath, A
MsgBox, %Path%
答案1
取得目前活動腳本的路徑:
F1::MsgBox, "%A_ScriptFullPath%"
https://www.autohotkey.com/docs/Variables.htm#prop
在 Windows 照片檢視器或 potplayer 中取得活動檔案的路徑:
; Get the path of the recent items folder
RegRead, Recent, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders, Recent
F2::
WinGetActiveTitle, active_title
active_title := StrSplit(active_title," - Windows Photo Viewer").1
active_title := StrSplit(active_title," - PotPlayer").1
If FileExist(Recent "\" active_title ".lnk")
{
FileGetShortcut, %Recent%\%active_title%.lnk, path
MsgBox, "%path%"
}
else
MsgBox, path not found
return
https://www.autohotkey.com/docs/commands/FileGetShortcut.htm