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:
Code: Select all
PPTvariable := ComObjActive("PowerPoint.Application").ActivePresentation.FullName
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:
Code: Select all
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)
._NewEnum()
; Get first matching process.
if queryEnum[process]
{
haystack := StrSplit(process.CommandLine,"`"`"")[4]
}
}