Jump to content

IE and PDF


Recommended Posts

Hi All,

I have a a number of scripts interacting with IE to automate some stuff at work. Most of the scripts involve going over links in an Excel file or clicking on links on a website. It usually works fine until it navigates to a page that is a PDF.

From what I've seen on the forums and what I've put together myself, when the script opens a PDF it is no longer part of IE.

After a PDF is opened _IENavigate no longer works. Is there anything I can do to navigate to a different page after going to a PDF?

I can't ignore PDF links as they are important to work. _IEQuit doesn't work after a PDF the PDF is opened. IENavigate also doesn't work after a PDF has been opened.

Link to comment
Share on other sites

Have you Try this ?

_IEAction ( $oIE, "back" )

Yeah, that also doesn't work.

I'm pretty sure what happens is that opening a PDF is causing adobe to override IE (I think I saw something similar mentioned in a different post from a year or two ago). So it seems like anything related to IE just doesn't work.

Since I have

$oIE = _IECreate()

Is there any way I can use $oIE to get control of IE again?

Link to comment
Share on other sites

Yeah, that also doesn't work.

I'm pretty sure what happens is that opening a PDF is causing adobe to override IE (I think I saw something similar mentioned in a different post from a year or two ago). So it seems like anything related to IE just doesn't work.

Since I have

$oIE = _IECreate()

Is there any way I can use $oIE to get control of IE again?

Give me your pdf url for try !

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Try Like This :

#include <IE.au3>

$_PdfUrl = 'http://www.mass.gov/Eeohhs2/docs/dph/cdc/factsheets/hga_hge.pdf'
$oIE= _IECreate ( $_PdfUrl, 0 , 1, 0 )
ConsoleWrite ( "-->- 1 : _IECreate" & @Crlf )
Sleep ( 1000 )
ConsoleWrite ( "-->- 2 :  Sleep" & @Crlf )
_IEAction ( $oIE, "home" )
ConsoleWrite ( "-->- 3 : _IEAction" & @Crlf )

And I think _IEAction ( $oIE, "back" ) would work too, if a page was open before...Posted Image

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

Try Like This :

#include <IE.au3>

$_PdfUrl = 'http://www.mass.gov/Eeohhs2/docs/dph/cdc/factsheets/hga_hge.pdf'
$oIE= _IECreate ( $_PdfUrl, 0 , 1, 0 )
ConsoleWrite ( "-->- 1 : _IECreate" & @Crlf )
Sleep ( 1000 )
ConsoleWrite ( "-->- 2 :  Sleep" & @Crlf )
_IEAction ( $oIE, "home" )
ConsoleWrite ( "-->- 3 : _IEAction" & @Crlf )

And I think _IEAction ( $oIE, "back" ) would work too, if a page was open before...Posted Image

What you did works if the PDF is the first link you go to, however this doesn't work and is more like what my script will be doing

#include <IE.au3>

$_PdfUrl = 'http://www.mass.gov/Eeohhs2/docs/dph/cdc/factsheets/hga_hge.pdf'
$oIE= _IECreate ( "http://www.google.com", 0 , 1, 0 )
ConsoleWrite ( "-->- 1 : _IECreate" & @Crlf )
Sleep ( 1000 )
ConsoleWrite ( "-->- 2 :  Sleep" & @Crlf )
_IENavigate($oIE, $_PdfUrl)
Sleep ( 1000 )
ConsoleWrite ( "-->- 3 :  Sleep" & @Crlf )
_IEAction ( $oIE, "home" )
ConsoleWrite ( "-->- 4 : _IEAction" & @Crlf )

The script will be pulling links from excel and going to each link, waiting for X number of seconds, then going to the next link. In my script, and the example above once it gets to the PDF it isn't able to continue.

Link to comment
Share on other sites

Your script is hanging in _IELoadWait waiting for a complete state from the document that never arrives. It will timeout by default after 5 minutes. You can explicitly set the LoadWait Timeout with _IELoadWaitTimeout and you will get a return value from _IECreate or _IENavigate that you can trap and act upon (note that _IECreate and _IENavigate both call _IELoadWait for you by default).

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Your script is hanging in _IELoadWait waiting for a complete state from the document that never arrives. It will timeout by default after 5 minutes. You can explicitly set the LoadWait Timeout with _IELoadWaitTimeout and you will get a return value from _IECreate or _IENavigate that you can trap and act upon (note that _IECreate and _IENavigate both call _IELoadWait for you by default).

Dale

Ahh, ok I see what you're saying.

Doing a test where I lowered the LoadWait Timeout got the script to continue. Thanks!

Link to comment
Share on other sites

Like this

#include <IE.au3>

$_PdfUrl = 'http://www.mass.gov/Eeohhs2/docs/dph/cdc/factsheets/hga_hge.pdf'
$oIE = _IECreate ("www.autoitscript.com" )
_IELoadWait ( $oIE )
ConsoleWrite ( "-->- 1 : _IECreate" & @Crlf )
_IENavigate ( $oIE, $_PdfUrl, 0 )
_IELoadWait ( $oIE, '', 5000 )
ConsoleWrite ( "-->- 2 : _IENavigate" & @Crlf )
Sleep ( 1000 )
ConsoleWrite ( "-->- 3 :  Sleep" & @Crlf )
_IEAction ( $oIE, "back" )
ConsoleWrite ( "-->- 4 : _IEAction" & @Crlf )

Otherwise you can detect the pdf by the end of the url !

If StringRight ( $_Url, 4 ) <> '.pdf' Then _IENavigate (...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

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...