Can I use the control Manager to run menu commands in Adobe Reader?

Started by RAK, August 04, 2015, 06:58:19 AM

Previous topic - Next topic

RAK

I have an script that opens Adobe Reader and runs a few menu items using sendkeysto. It can disturb the user. I am about to create a 'wait for no user input' script o avoid this but it would be awesome If I could make it run completely hidden.

thanks
Roy

DAG_P6

Roy,

Quote from: RAK on August 04, 2015, 06:58:19 AM
I have an script that opens Adobe Reader and runs a few menu items using sendkeys to. It can disturb the user. I am about to create a 'wait for no user input' script o avoid this but it would be awesome If I could make it run completely hidden.

There have been plenty of times when I had the same desire. Since your script runs "a few menu commands," asking it to run completely hidden is probably asking too much. When confronted with similar circumstances, my solution was to lock the keyboard while my script ran. That was so long ago that I have long since forgotten how I did it, but it was a WIL command, because the script was pure WinBatch, circa 1997.

Another thing to consider is finishing up with a command to set the focus to the desired window, such as, maybe "self."
David A. Gray
You are more important than any technology.

td

Quote from: RAK on August 04, 2015, 06:58:19 AM
I have an script that opens Adobe Reader and runs a few menu items using sendkeysto. It can disturb the user. I am about to create a 'wait for no user input' script o avoid this but it would be awesome If I could make it run completely hidden.

thanks
Roy

WinBatch has the SendMenusTo function that you might what to at least check out.  You also might want to check out Acrobat's COM Automation interfaces.  Both of which may or may not be useful depending on  what you are attempting to do.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

Thanks but locking the keyboard is not an option. Com automation only applies to the full version of acrobat correct? My clients are using reader.

I was about to switch to sendmenusto but wanted to know if I could hide it all with the control manager.  Will sendmenusto override user input and not fail when fighting the user for focus?

Please confirm that Control Manager will not work with the Adobe reader.

td

COM automation isn't only available for the full version.

The Control Manger as the name implies works with Windows common and user controls.  Menus are not controls.   It is unclear what you are trying to hide exactly but you can't use control manager to hide a menu.   Whether or not Control manger will work with Acrobat Reader depends on what you are trying to do.  Only a few of the app's windows can be manipulated using the Control Manager. 

You can always very temporarily disable input if you are worried about user interference. The time it takes to disable and re enable input can be very brief.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

Quote from: td on August 05, 2015, 01:11:26 PM
COM automation isn't only available for the full version.

The Control Manger as the name implies works with Windows common and user controls.  Menus are not controls.   It is unclear what you are trying to hide exactly but you can't use control manager to hide a menu.   Whether or not Control manger will work with Acrobat Reader depends on what you are trying to do.  Only a few of the app's windows can be manipulated using the Control Manager. 

You can always very temporarily disable input if you are worried about user interference. The time it takes to disable and re enable input can be very brief.

Com automation would be awesome. I can load a AcroRd32.exe object?! My goal is to hide the complete window and perform select all and copy functions. Is there any sample documentation so I have the object name etc.?

This is great news.
Thanks
Roy

RAK

I have been searching for docs.. I found http://help.adobe.com/livedocs/acrobat_sdk/10/Acrobat10_HTMLHelp/wwhelp/wwhimpl/js/html/wwhelp.htm?&accessible=true

Do I need the SDK to use COM automation? The solution must function in users machines that have only the reader. Is com still an option in this situation?

I have tried: ObjectCreate("AcroExch.App") and many others and cannot seem to create an object.

thanks
Roy

td

You can use the WIL Type Viewer (that is part of your WinBatch Distribution) to search for available COM Automation servers and you can also search the Tech Database on the term 'Adobe' to find examples.  Some of the Tech Database articles are old and things have changed a bit but they should still provide some insights.

For example, the Type Viewer shows several interesting progids on my system including 'AdobeAcrobat.OpenDocuments.3' and 'AcroPDF.PDF.1'.  Whether or not these my be of use to you is unknown because you didn't indicate what exactly you are attempting to do.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

My goals are in a prior post...
My goal is to hide the complete window and perform: select all, copy and exit functions.

I want the text in the window.. If there is a better way to get it that would improve the inconsistency of parsing text, that would be even better..

THANKS!

RAK

I used the type viewer as you suggested and at first glance the feature list looks robust. I attempted to create an object ObjectCreate("AcroExch.App") but it fails. Any reason you can think of that I am failing?

Before I posted here I found this in a post:
Note: In order to use the OLE object made available by Acrobat Reader, you must have the full Acrobat product installed on your system. You need the Acrobat Viewer, PDF development too, and Acrobat Exchange to do OLE.

just now I found Article W15621 that shows some functions.

....IFICantBYTE

According to the official Adobe documentation for Reader's OLE/IAC functionality, you can't do exactly what you want to do.
You could probably host it and control it via WinBatch, but there are only limited functions available.
To solve your specific problem, maybe you could use the PrintAll function and print to a file rather than a real printer?
Alternatively, perhaps a different "free" PDF reading application/api you can bundle with your script might be a better solution?

... the following text is taken from the official Adobe document ( http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/reader_overview.pdf) :

On Windows, the only OLE automation supported for Adobe Reader is the PDF browser controls interface, which enables you to treat a PDF document as an ActiveX document within an external application. This makes it possible to load a file, move to various pages within the file, highlight a text selection, and specify various print and display options, as shown below.
PDF browser controls
Adobe Acrobat SDK Interapplication Communication
Developing for Adobe Reader OLE automation 26
PDF browser controls are available through the AxAcroPDFLib.AxAcroPDF interface, which provides the following methods used to programmatically control the PDF document window:
ââ€"GoBackwardStack
ââ€"GoForwardStack
ââ€"GotoFirstPage
ââ€"GotoLastPage
ââ€"GotoNextPage
ââ€"GotoPreviousPage
ââ€"LoadFile
ââ€"Print
ââ€"PrintAll
ââ€"PrintAllFit
ââ€"PrintPages
ââ€"PrintPagesFit
ââ€"PrintWithDialog
ââ€"SetCurrentHighlight
ââ€"SetCurrentPage
ââ€"SetLayoutMode
ââ€"SetNamedDest
ââ€"SetPageMode
ââ€"SetShowScrollbars
ââ€"SetShowToolbar
ââ€"SetView
ââ€"SetViewRect
ââ€"SetViewScroll
ââ€"SetZoom
ââ€"SetZoomScroll
Regards,
....IFICantBYTE

Nothing sucks more than that moment during an argument when you realize you're wrong. :)

td

Quote from: RAK on August 06, 2015, 11:57:20 AM
I used the type viewer as you suggested and at first glance the feature list looks robust. I attempted to create an object ObjectCreate("AcroExch.App") but it fails. Any reason you can think of that I am failing?

Before I posted here I found this in a post:
Note: In order to use the OLE object made available by Acrobat Reader, you must have the full Acrobat product installed on your system. You need the Acrobat Viewer, PDF development too, and Acrobat Exchange to do OLE.

just now I found Article W15621 that shows some functions.

Not sure why you are want to use the 'AcroExch.App' progid and not take a look at the the 2 previously mentioned progids.  If you click on the 'Programmatic Identifier List' tab in the Type Viewer, you can search  all the identifiers available on your system.  Once you find Acrobat related progids, you can then look at the available  methods and properties. 

For example, the 'AcroPDF.PDF.1' is available on my notebook computer ( it has neither the SDK or the full version of Acrobat installed) and it definitely is usable in a WinBatch script via the ObjectCreate function.  But as IFICantBYTE mentioned, it would require some kludging to get it to do what you want. 

Acrobat is also an DDE server but I have never tried to use that piece of functionality and can't provide much insight.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

QUOTE "definitely is usable in a WinBatch script via the ObjectCreate function"

So I tried and cannot even find the app name to create the object.  ObjectOpen("???.Application")?

While reading - I read a wrapper (like IE) is required to use some of the functions. That sounded promising as I am quite familiar with IE and OLE - 'OLECMDID_SELECTALL and _COPY functions popped in to my head.  I cannot seem to get them to work.. I can print and refresh using OLECMDID, but the select all function fails with an error. I am opening the PDF file in IE.. Just want a method that can work without disturbing the user or stealing focus from them..

Could I ask for help with 'OLECMDID_SELECTALL' and 'OLECMDID_COPY" and if they are no longer allowed, then 'OLECMDID_SETTITLE' as the windows opens with No name. browser.documentt.title fails also - maybe because there is no 'document' section.

thanks
Roy



td

Quote from: RAK on August 17, 2015, 07:47:48 PM
QUOTE "definitely is usable in a WinBatch script via the ObjectCreate function"

So I tried and cannot even find the app name to create the object.  ObjectOpen("???.Application")?


For the third time, there is no Adobe '*.application' available without the full Acobat+Reader.  My statement specifically referred to the progid 'AcroPDF.PDF.1' which does load into WinBatch and is available on systems with Acrobat Reader but doesn't provide much support for what you are attempting to do.

As for the Command Target commands, your experience with using  the IOleCommandTarget interface exactly parallels the methods offered by the object created using the 'AcroPDF.PDF.1'.  This may (or may not) explain why you can't get some IOleCommandTarget commands to work as the targeted object still needs to implement the commands.  Also note that the 'AcroPDF.PDF.1' object has the 'execCommand' method which may (but likely not) give you access to the IOleCommandTarget implementation without the need for 'opening the PDF file in IE.'  However, you may experience the same limitations you experienced with IE and it doesn't seem to be documented.

And finally, because an object supports one  IOleCommandTarget command does not mean it supports all of them. 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

If you wish help with your current IE approach, provide a simple example of what you have tried and we might be able to determine if it can be made to work.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

According to Adobe, starting with Acrobat and Reader 7.0.5 the MSFT IFilter interface is supported directly.  You can find C# code that wraps the interface and it could conceivably be compiled and used by WinBatch CLR hosting.  I have never tried to use this interface on a PDF file so I cannot say that it is worth pursuing.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

td

It appears MSFT has dropped support for the IFilter interface and blocks its use in Managed code on Windows 7 and newer, so that idea is just another dead end.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

Quote from: td on August 18, 2015, 07:56:55 AM
If you wish help with your current IE approach, provide a simple example of what you have tried and we might be able to determine if it can be made to work.

Thanks for your help..

I am simply opening an IE session with the a local pdf file as the url. Then I am trying to select all,  copy, and exit. I expect that sendkeysto will not work with a hidden window and will expose the window if it is minimized. Can I send menu commands to IE if the window is minimized or not visible?

td

The comment you quoted was specifically referring to the use of 'the IOleCommandTarget' interface but I doubt that sending keys to IE would cause IE to become visible. However that would take less than a 10 line script for you to test.  Your more likely problem will be getting the timing down so that IE is ready to accept keys.  I don't think the usual browser 'busy' or 'ReadyState' methods will work for that nor will the  WinWaitReady function likely solve the problem either.  You may be left with simply using a couple of second TimeDelay
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

Quote from: td on August 20, 2015, 09:24:52 AM
The comment you quoted was specifically referring to the use of 'the IOleCommandTarget' interface but I doubt that sending keys to IE would cause IE to become visible. However that would take less than a 10 line script for you to test.  Your more likely problem will be getting the timing down so that IE is ready to accept keys.  I don't think the usual browser 'busy' or 'ReadyState' methods will work for that nor will the  WinWaitReady function likely solve the problem either.  You may be left with simply using a couple of second TimeDelay

Yes I have tried it already. The issue is that when I open the local pdf - the window name is blank and I cannot access the .title property to set it. I cannot send the keys to a no name window. I just tried to open a local html file and then navigate to the pdf but same issue - blank title after navigation. Maybe a 'writein' with a local href to the file will give me a page title to use with sendkey?

Just to confirm, send menus to is ng?

thanks again.


td

Depending to some extent on your OS and IE version, "Internet Explorer" may be sufficient.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

RAK

Done - it's awesome as it works while invisible!

thanks - I appreciate for your efforts.
Roy