What am I doing wrong?

I’m trying to write a script that will open up a specific URL in a new browser window, and then download it. Here’s what I’ve got:

tell application “Internet Explorer”
set explorerwindow to OpenURL “www.target.com/index.html” toWindow 0
Activate explorerwindow
set currentSource to GetSource
CloseWindow explorerwindow
end tell

So the first bit line opens the window fine, but my problem comes up when it comes to the “set currentSource to GetSource” it gives me a “paramater error” when I try to run it.

If I get rid of the “toWindow 0” option on the “set explorerwindow to OpenURL” line, then it works fine, but it opens in the topmost internet explorer window. So any ideas on what I’m doing wrong, or another way I might do it?

Consider that when you activate IE, initially it will access your home, which I don’t believe you want to view.
Try:

tell application “Internet Explorer”
Activate
CloseWindow -1
set explorerwindow to OpenURL “www.target.com/index.html” toWindow 0
Activate explorerwindow
set currentSource to GetSource
CloseWindow explorerwindow
end tell

Does this do what you want ?
:?:

I’m completely lost as to why you’re using IE to do this at all. Why not do it directly and do away with window ordering, etc.:


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]

I find “URL Access Scripting” to be buggy for me. I prefer using CURL:

Jon


[This script was automatically tagged for color coded syntax by Convert Script to Markup Code]