Autohotkey: Ich kann den Pfad der aktiven Datei nicht abrufen

Autohotkey: Ich kann den Pfad der aktiven Datei nicht abrufen

ich möchte den Pfad der aktiven Datei erhalten.

aktiver Dateipfad: C:\Benutzer\e\Desktop\1w.jpg"

Autohotkey-Ergebnis: C:\Windows\System32\dllhost.exe

Code:

q::
WinGet, Path, ProcessPath, A
MsgBox, %Path%

Antwort1

Holen Sie sich den Pfad des aktuell aktiven Skripts:

F1::MsgBox, "%A_ScriptFullPath%"

https://www.autohotkey.com/docs/Variables.htm#prop

Holen Sie sich den Pfad der aktiven Datei im Windows-Fotoanzeiger oder im 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

verwandte Informationen