Skip to main content

Download-File

Command Description

Use a browser to download files from a specified link

Command Prototype

WebBrowser.Download(hWeb,sURL,sFile,bSync,iTimeOut,optionArgs)

Parameter Description

ParameterRequiredTypeDefaultDescription
hWebTrueexpressionhWebBrowser handle string using WebBrowser.create or WebBrowser.bind Command Returns
sURLTruestring""The link address (URL) to download file
sFileTruepath'''C:\Users'''The path to save the downloaded file locally
bSyncTruebooleanTrueThe command is run synchronously, and then returns to TRUE and wait for the file download to return to continue, transfer to false, then return to return immediately after downloading
iTimeOutTruenumber300000The timeout for the file to be downloaded. If it expires, it is determined that the download fails. The default time is 300000 milliseconds (5 minutes)
bContinueOnErrorNonebooleanNoneSpecify whether the automation should continue to support this field even if the activity is incorrect, it is only supported by the Boolean value (true, false) default value
iDelayAfterNonenumber300Delay time (in milliseconds) after executing the activity is 300 milliseconds
iDelayBeforeNonenumber200The delay time (in milliseconds) before any operations are executed is by default 200 milliseconds

Demo

/*********************************download file************** ************************ 
Command prototype:
WebBrowser.Download(hWeb,sURL,sFile,bSync,iTimeOut,optionArgs)
Input parameters:
hWeb--Browser object
sURL--the link address (URL) of the file to be downloaded
sFile--path where the downloaded file is saved on this computer
bSync--Whether the command is executed synchronously
iTimeOut--timeout time for waiting for file download
bContinueOnError--whether to continue after error
iDelayAfter-- delay after execution
iDelayBefore--delay before execution
*********************************************************************************/
Dim hWeb,bRet
hWeb = WebBrowser.Create("ie","www.baidu.com",30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200,"sBrowserPath":"","sStartArgs":""})
TracePrint(hWeb)
hWeb = WebBrowser.BindBrowser("ie",10000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
TracePrint(hWeb)
iRet = WebBrowser.GoURL(hWeb,"https://laiye.com/download?source=product-process-creator-banner",false,{},30000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})
TracePrint(iRet)
WebBrowser.Download(hWeb,"https://down.uibot.com.cn/onekernel/6.0.0/UiBot_Community_Official_X86_V6.0.0_2021.12.15.2018.exe",'''C:\Users\Downloads''',true,60000,{"bContinueOnError":false,"iDelayAfter":300,"iDelayBefore":200})