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