Autohotkey:我无法获取活动文件的路径

Autohotkey:我无法获取活动文件的路径

我想获取活动文件的路径。

活动文件路径:C:\Users\e\Desktop\1w.jpg”

autohotkey 结果: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

相关内容