Jump to content

Auto It get active Acrobat filename


 Share

Go to solution Solved by Jfish,

Recommended Posts

Global $oExcel = _Excel_Open()
Global $oWorkbook = $oExcel.ActiveWorkbook
MsgBox(0,"Test",$oWorkbook.Name)

Global $oWord = _Word_Create()
Global $oDoc = _Word_DocGet($oWord, 1)
$oDoc.Name
MsgBox(0,"Test",$oDOc.Name)

Above code used to get active file for Excel and Word. How do I do the same for Acrobat files. Please advice. Thanks.

Link to comment
Share on other sites

Use the RUN command (perhaps also check out PID with that, and Process commands), along with WinGetHandle and Window Titles and Text (Advanced) (check the Advanced Window Descriptions section) ... all in the Help file.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

Use the RUN command (perhaps also check out PID with that, and Process commands), along with WinGetHandle and Window Titles and Text (Advanced) (check the Advanced Window Descriptions section) ... all in the Help file.

I don't have the filename. User might open any Acrobat file. For an example, user may open A.pdf or B.pdf or C.pdf. I need to get the filename of what file they opened. 

Edited by tauruzian
Link to comment
Share on other sites

Use the RUN command (perhaps also check out PID with that, and Process commands), along with WinGetHandle and Window Titles and Text (Advanced) (check the Advanced Window Descriptions section) ... all in the Help file.

 

I don't have the filename.

 

It is abundantly clear from the title and the first post that you want to get the filename.  If you reply to every post restating that you dont have the filename, and want to get the filename, this is going to get real quiet real quick.  You should re-read (or read for the first time, its hard to tell) Saint's post and actually try those things before posting again.

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

I would add one thing to what TheSaint said.  The method he referenced is a different approach to the examples you posted to get you the same answer.  His is much simpler than the alternative using the Adobe API (which is for Acrobat not Reader).   If you have Acrobat and you want to give it a go you can see the documentation here.  That documentation does include a way to get the active document / filename but I think that you will find it much harder then what TheSaint recommended.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

I don't have the filename. User might open any Acrobat file. For an example, user may open A.pdf or B.pdf or C.pdf. I need to get the filename of what file they opened. 

I took from your initial post, that you were the one opening the Excel or Word document.

There are ways to get some of your info, by checking on whether Adobe Acrobat is running (i.e. ProcessExists), then get a list of existing windows and finding the active one maybe or a title that ends in .pdf.

In the Examples section here, there are scripts that can help you do what you want, and probably even here in GH&S. Search for things like process path, and other related things like the Window Info Tool.

Failing that, I would go the mentioned API route.

P.S. There is a good chance, that someone has already done what you are attempting, and a script exists here somewhere.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

  • Solution

This was tested and should work with Acrobat (not Reader):

$App = ObjCreate("AcroExch.App")
$App.Show
$avdoc = $App.GetActiveDoc
$PDDoc = $avdoc.GetPDDoc()
$name=$PDDoc.GetFileName()
ConsoleWrite(@crlf&"***"&$name&"***"&@crlf)

Also, I have Acrobat Pro v 8 which is older.  You may need to update this if the IAC changed for later versions.

Update:  I believe from researching this that the only way to do it through Reader is through the use of a plugin.  I am not 100% on that but Reader is much more limited.  The SDK has several examples with header files that are a bit over my head (pun intended).

Edited by Jfish

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...