Determine the path of an open file

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Determine the path of an open file

Post by kpassaur » Thu Oct 27, 2005 6:11 pm

Any ideas on how to determine the path of an open file? I can get the filename from the window; however, I would like path to the open file so I can move and rename it. In most cases I could just save the file to another location, however, I am using Acrobat Reader, not the full version so I cannot save it. The file will not always be opened from the same folder. For instance, it could be in My Documents or the temp folder.

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Fri Oct 28, 2005 4:26 pm

This script will tell you the process ID and file location of the active window.


wait>2
GetActiveWindow>window_name,X,Y
GetWindowProcess>%window_name%,process_id,name_and_location
MessageModal>Process ID: %process_id%%CRLF%Location: %name_and_location%

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Re: Determine the path of an open file

Post by Monkster » Sat Oct 29, 2005 10:30 pm

kpassaur wrote:Any ideas on how to determine the path of an open file? I can get the filename from the window; however, I would like path to the open file so I can move and rename it. In most cases I could just save the file to another location, however, I am using Acrobat Reader, not the full version so I cannot save it. The file will not always be opened from the same folder. For instance, it could be in My Documents or the temp folder.
Hi kpassaur,


If I understand your question correctly couldn't use the Adobe Reader command "Save a Copy" without anything futher?

In any event, this should do the trick:


//Tested using Adobe Reader 7.05
Let>MSG_WIDTH=640
Let>MSG_HEIGHT=400
SetFocus>Adobe Reader*
Press CTRL
Send>d
Release CTRL
WaitReady>0
GetWindowText>Document Properties,PDFiNFO
PutClipBoard>%PDFiNFO%
Press ESC
Position>Location:,%PDFiNFO%,1,ps
Let>ps=ps+11
Position>File Size:,%PDFiNFO%,1,pe
Let>pe=%pe%-%ps%
Let>pe=%pe%-2
MidStr>%PDFiNFO%,ps,pe,thePath
Position>File:,%PDFiNFO%,1,fnStartTmp
Let>fnStart=fnStartTmp+7
Position>Title:,%PDFiNFO%,1,fnEnd
Let>theFileLength=%fnEnd%-%fnStart%
Let>theFileLength=%theFileLength%-2
MidStr>%PDFiNFO%,fnStart,theFileLength,theFile
Let>aaa=This is the path to the file:%CRLF%%CRLF%%thePath%%CRLF%%CRLF%%CRLF%
Let>bbb=This is the filename:%CRLF%%CRLF%%theFile%%CRLF%%CRLF%%CRLF%
Let>ccc=This is the fully qualified path:%CRLF%%CRLF%%thePath%%TheFile%
MessageModal>%aaa%%bbb%%ccc%
Best Wishes,
Monkster

kpassaur
Automation Wizard
Posts: 696
Joined: Wed Jul 07, 2004 1:55 pm

Thank you

Post by kpassaur » Mon Oct 31, 2005 3:45 pm

Script works like a charm for PDF's

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts