
アクティブファイルのパスを取得したい。
アクティブファイルパス: 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