So, recently I had to figure out how to discover the path of a file that was opened in PowerPoint (NOT the path of the PowerPoint executable). I eventually found this code:
PPTvariable := ComObjActive("PowerPoint.Application").ActivePresentation.FullName
It worked well however it often would throw errors. One was a nul error due to the time between the PowerPoint process being started and the ActivePresentation being loaded, so I wouldn't get the path. Secondly was that the ahk script needed to run as admin and sometimes PowerPoint wasn't running as admin, so I would get an error and no path.
Obviously, Process command would be cool, however, it does not give the path of the opened file, it only gives the path to the process.
Eventually I found the answer in the forums here: https://autohotkey.com/boards/viewtopic.php?t=25530 that works almost as immediately as the process is started.
The Code is:
Process, Exist, POWERPNT.EXE
If (Errorlevel <> 0)
NewPID = %ErrorLevel%
; will get full path name of the currently open file.
wmi := ComObjGet("winmgmts:")
; Run query to retrieve matching process(es).
queryEnum := wmi.ExecQuery(""
. "Select * from Win32_Process where ProcessId=" . NewPID)
; Get first matching process.
haystack := StrSplit(process.CommandLine,"`"`"")
Would it be possible to add this code into the process command as a separate option? Obviously it would start from the wmi line, rather than the first line of code but I left all that in there so you could have a simple test to start with. the haystack line splits the command via parenthesis and targets the 4th token as that is the path to the opened file.