From iMacros
Jump to: navigation, search

iMacros automatically detects and intercepts downloads. With this command, which has to occur before the download starts, the location and name of the saved file is determined. The general web page timeout also applies to downloads. Make sure that the timeout value is long enough to cover the complete download time.

Normally the download file name is created automatically by the website. You can add parts to the original file name by using the + syntax (see Examples). The built-in variable !NOW is helpful in this context.

iMacros can calculate the checksum of a downloaded file and compare it with the value of the CHECKSUM parameter. This is very useful to verify that file downloads are not corrupted, or worse, have been infected by a virus or trojan horse (e. g. via a hacked server). Both the MD5 and the SHA1 checksums are supported.

Important notes:

  • The maximum allowed download time is set by !TIMEOUT_PAGE (60s by default). So it is treated as page download (timeout wise). If you need to allow longer file downloads, please increase this value e. g. with SET !TIMEOUT_PAGE 300. If the download is completed before 5 min (300s) are over, the macro continues. Otherwise you get a timeout error.
  • VERY IMPORTANT: The macro must still be running when the download dialog appears, otherwise iMacros can not catch it. Often websites need a few seconds for the download to start, so make sure the macro is still active then, e. g. by adding a short wait statement at the end. This wait time is not for the download itself, but only for the time the site needs for the download dialog to appear. If the macro continues with other commands, you will not need such a WAIT statement, you need it only when the download is at the end of the macro.


 URL GOTO= http://www.opera.com/download/get.pl?id=32799&location=326¬hanks=yes&sub=marine
 'Wait for download to _start_, afterwards iMacros waits for the completion automatically
  • If the download does not start before the end of the macro, iMacros will wait for up to an additional !TIMEOUT_STEP seconds before aborting with error -1410: No Download Detected.

Syntax iMacros Browser IE Plug-in Firefox

ONDOWNLOAD FOLDER=folder_name FILE=file_name WAIT=[YES|NO] CHECKSUM=[MD5|SHA:hexadecimal_string]




    Specifies the folder in which the file is saved. Use * for the standard download folder specified in the options.
    Note that blank spaces in the path need to be replaced by "<SP>" like in "c:\my<SP>folder" (instead of "c:\my folder")
  • FILE
    Specifies the file name under which the file is saved. If no file extension is given, the default file extension is used. Use * for the original file name. Use +something to add something to the original file name before the file extension.
  • WAIT
    Specifies if iMacros should wait for the download to complete (WAIT=YES) or continue with the macro without waiting (WAIT=NO), Default is YES
    Calculates the checksum of a downloaded file and compares it with the value specified (as a hexadecimal string), using either MD5 or SHA-1 hash functions. Note: CHECKSUM requires WAIT=YES.
  • CANCEL iMacros Browser IE Plug-in
    Stops automatic download from websites. Note, the CANCEL parameter is implemented in versions above iMacros v9.01 and is not available in iMacros for Firefox and Chrome yet.


Suppose you download a file originally called setup.exe. The following snippet will save this file under the original file name in the default folder:


This command will save the file in the C:\MyFiles\ folder under the name myDownload.exe:

ONDOWNLOAD FOLDER=C:\MyFiles\ FILE=myDownload.exe 

And finally, this command will save the file in the default directory under the name with an added date stamp (using the !NOW variable), e.g. setup_060525.exe.


Note: The "+" symbol is only required if you want to add text to the default file name (as created by the website). In this case, "+" must be the first symbol, directly after FILE=+... . The "+" is not required (and not allowed) if you want to concatenate several variables. To concatenate variables just use them as part of the string. Example: FILE=invoice_no{{number}}_unit{{departement}}.pdf

You can verify the integrity of the downloaded file using the CHECKSUM parameter. Here the expected checksum was previously calculated as a hexadecimal string using the SHA-1 function.


In case you want to avoid (single or multiple) automatic downloads, you can make use of the CANCEL parameter. The CANCEL parameter can be specified only when other parameters are omitted and is effective until one of the following commands occurs: ONDOWNLOAD CANCEL=NO, or ONDOWNLOAD FOLDER=... FILE=...


Example macros: Demo-FileDownload, Demo-ImageDownload

PDF Downloading

Please make sure you uninstall or disable PDF handling browser addons, such as Adobe. Then the browser prompts you to download the PDF as regular download - and iMacros can automate it.

Automating, testing and monitoring PDF file downloads is easy with iMacros.

See also: Prevent IE from opening PDFs

Website for testing: PDF Download Test


  1. The download dialog needs a short while to appear after it is triggered and iMacros should to be running to catch it. If the macro ends right after the command which triggers the download, iMacros will not be able to catch the dialog. In this case, we suggest adding
after the command which triggers the download. This gives iMacros time to wait for the dialog.
The parameter WAIT=YES refers to another waiting, namely after the download has started it should wait for the download to complete.
  1. In Internet Explorer (but not the iMacros Browser) you need to enable the automatic prompting for downloads, to avoid the notification bar.
  2. It is highly necessary to have the option to hide file extensions (in Windows Explorer) disabled! Otherwise, iMacros may fail to rename the file when specifying something other than the original file name (e.g. when not using the default FILE=*).
  3. FOLDER does not accept relative path, FILE does. In case you want to download to a subfolder under the iMacros downloads folder, you can use the FILE parameter, but that subfolder needs to exist prior to the download.
  4. Just the FOLDER parameter creates folders, so if the folder is not there yet, it has to appear in FOLDER, not in FILE.

Related Forum Posts

For iMacros for Firefox:


See Also