Download a File using Internet Explorer 3.05

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Download a File using Internet Explorer 3.05

Post by Marcus Tettmar » Fri Apr 24, 1998 11:00 pm

Contributed By: Marcus Tettmar [email protected]
Submitted On: 25/04/98

//This script shows how to automate Internet Explorer to download
//a file from the Internet.  In this case it is a .zip file.

//You may want to insert a call to another macro here to
//dial up to the Internet. And likewise, disconnect at the end.
//See http://www.mjtnet.com/forum/viewtopic.p ... connecting to see
//how to automate dial up networking

//Variable Declarations
Let>DownloadFile=http://www.mjtnet.com/software/msched.zip
Let>LocalFile=c:\my documents\msched.zip
Let>Overwrite=TRUE

//If Internet Explorer is Not Open - Start It
IfWindowOpen>Internet Explorer*,StartDownload
Let>I_Opened_IE=TRUE
Run Program>"C:\Program Files\Plus!\Microsoft Internet\Iexplore.exe"
WaitWindowOpen>Microsoft Internet Explorer*

//Start the Download
Label>StartDownload
SetFocus>Microsoft Internet Explorer*
Press ALT
Send Character/Text>FO
Release ALT
WaitWindowOpen>Open
Send Character/Text>DownloadFile
Press Enter
WaitWindowOpen>File Download

//Wait for the box asking if we want to open the file or save it.
//Remove this part if your IE is set to bypass this box.
Wait>2
WaitWindowOpen>Internet Explorer
Wait>2
Press Enter

//Wait for the Save As box
WaitWindowOpen>Save As
Wait>2
Send Character/Text>LocalFile
Press Enter
Wait>2

//Here we try to detect the warning dialog telling us that
//the file already exists.  We tell it whether to overwrite or
//not - depending on the setting of the Overwrite variable
//A way to avoid this box appearing would be to see if the local
//file already exists and if so delete it before starting the download
//in the first place.
FindWindowWithText>Yes,0,title,0
If>title=Save As,OverwriteFile
Goto>Continue
Label>OverwriteFile
If>Overwrite=TRUE,Press Yes
Send Character/Text>N
Label>Press Yes
Send Character/Text>Y

//Continue with download
Label>Continue
WaitWindowOpen>File Download
WaitWindowClosed>File Download

//Download finished.  If we started IE, we should close it.
If>I_Opened_IE=TRUE,CloseIt
Goto>End
Label>CloseIt
CloseWindow>Microsoft Internet Explorer*
Label>End

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts