Jump to content

IE page automatically downloads


Recommended Posts

Hi All,

I was just wondering how I could make AutoIT determine if a webpage prompts up to download a file, atm my code is as follows:

#include <IE.au3>
#include <Array.au3>
#include <File.au3>
If FileExists("file path") Then;you will need to change where the .txt is stored
Sleep(400)
Else
FileWrite("directory path","")
EndIf
local $links
_FileReadToArray("txt file",$links)
_ArrayDelete($links, 0)
$message=InputBox("Insert Message...","Insert Message...")
$log=FileOpen("directory path","1");you will need to change where the .txt is stored

For $link In $links

$oIE = _IECreate($link, 0, 1, 1, 0)
;_IELoadWait($oIE)
sleep(150)
$title = _IEPropertyGet( $oIE , "title")

If StringInStr($title, $message) > 0 Then
;blocked
FileWriteLine($log,$link&" message")
_IEQuit($oIE)
ElseIf StringInStr($title, "Error") Or StringInStr($title, "cannot") Or StringInStr($title, "Not Found") Or StringInStr($title, "Forbidden") > 0 Then
;error
FileWriteLine($log,$link&" - "& $title);displays the error in log file
_IEQuit($oIE)

ElseIf WinExists("File Download") Then
;page attempts to download
WinClose("File Download")
FileWriteLine($log,$link&" - Attempts to download file, missed")

Else
;missed
FileWriteLine($log,$link&" - Wooh!")
_IEQuit($oIE)
EndIf

Next

Everytime IE loads a webpage which prompts for a download the scripts ends with this error:

WEnd
WEnd^ ERROR

As you can see there are no While Loops in the script.

Thanks.

Edited by AutoAl
Link to comment
Share on other sites

Line 245 (File "C:UsersAdminDesktopurl_testurl_test.exe"):

Error: The requested action with this object has failed.

That error appears when I compile the script, once I run the script from editing mode it just shows

>"C:Program FilesAutoIt3SciTE..autoit3.exe" /ErrorStdOut "C:UsersAdminDesktopurl_testurl_test.au3"

C:\Program Files\AutoIt3\Include\IE.au3 (560) : ==> The requested action with this object has failed.:

WEnd

WEnd^ ERROR

>Exit code: 1 Time: 20.251

Sorry thought I pasted the whole of the error

Link to comment
Share on other sites

The error is coming from IE.au3 and is caused by a timing issue and the COM error handler. There is a fix in a development version of AutoIt, but for now, if you can isolate where in YOUR script this is triggered we can help find a workaround.

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

There must be something unique about the pages that cause this error, other than the fact that they prompt for file download. There is nothing inherent in that prompt that would cause this error.

You will either need to 1) more deeply troubleshoot the specific pages to see what can be implemented as a workaround, 2) run the AutoIt Alpha release with its new IE.au3 (I don't recommend this for reasons not related to IE.au3) or 3) run the latest AutoIt beta and copy the IE.au3 from the AutoIt Alpha release as it takes advantage of COM error handling changes introduced in the beta.

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

The pages I'm using are:

www.google.co.uk

www.facebook.com

www.aodngka.co.uk

http://download.thinkbroadband.com/1GB.zip

I will probably download the Autoit Beta and copy IE.exe see what happens, thanks a lot! :)

Al.

Link to comment
Share on other sites

Just to be clear, copy IE.au3 from the Alpha release (pointer in the forum) and run it with the beta.

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

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