NSIS 异步文件下载和自定义进度条
NSIS async file download and custom progress bar
是否存在 NSIS 插件或内置功能来异步下载文件并使用下载进度更新自定义进度条(使用 nsDialogs 创建)?
您可以使用INetBgDl plugin在后台下载文件并设计您自己的UI:
!include nsDialogs.nsh
!include LogicLib.nsh
Var hInfo
Var hPBar
Function myTimer
InetBgDL::GetStats
${If} = 0
${NSD_KillTimer} myTimer
${NSD_SetText} $hInfo "Completed. (Status=[=10=])"
SendMessage $hPBar ${PBM_SETRANGE32} 0 100
SendMessage $hPBar ${PBM_SETPOS} 100 0
Return
${EndIf}
IntOp +
StrCmp "" 0 +2
StrCpy "?"
${NSD_SetText} $hInfo "Status=[=10=]$\nCompleted of files$\nDownloaded of bytes"
SendMessage $hPBar ${PBM_SETRANGE32} 0
SendMessage $hPBar ${PBM_SETPOS} 0
FunctionEnd
Function myPage
nsDialogs::Create 1018
Pop [=10=]
${NSD_CreateLabel} 0 0 100% 50% "Starting download..."
Pop $hInfo
${NSD_CreateProgressBar} 0 55% 100% 10u ""
Pop $hPBar
${NSD_CreateTimer} myTimer 1000
InetBgDL::Get /RESET "https://download.mozilla.org/?product=firefox-41.0.2-SSL&os=win&lang=en-US" "$PluginsDir\ff.exe" /END
nsDialogs::show
${NSD_KillTimer} myTimer
FunctionEnd
Page Custom myPage
Page InstFiles
是否存在 NSIS 插件或内置功能来异步下载文件并使用下载进度更新自定义进度条(使用 nsDialogs 创建)?
您可以使用INetBgDl plugin在后台下载文件并设计您自己的UI:
!include nsDialogs.nsh
!include LogicLib.nsh
Var hInfo
Var hPBar
Function myTimer
InetBgDL::GetStats
${If} = 0
${NSD_KillTimer} myTimer
${NSD_SetText} $hInfo "Completed. (Status=[=10=])"
SendMessage $hPBar ${PBM_SETRANGE32} 0 100
SendMessage $hPBar ${PBM_SETPOS} 100 0
Return
${EndIf}
IntOp +
StrCmp "" 0 +2
StrCpy "?"
${NSD_SetText} $hInfo "Status=[=10=]$\nCompleted of files$\nDownloaded of bytes"
SendMessage $hPBar ${PBM_SETRANGE32} 0
SendMessage $hPBar ${PBM_SETPOS} 0
FunctionEnd
Function myPage
nsDialogs::Create 1018
Pop [=10=]
${NSD_CreateLabel} 0 0 100% 50% "Starting download..."
Pop $hInfo
${NSD_CreateProgressBar} 0 55% 100% 10u ""
Pop $hPBar
${NSD_CreateTimer} myTimer 1000
InetBgDL::Get /RESET "https://download.mozilla.org/?product=firefox-41.0.2-SSL&os=win&lang=en-US" "$PluginsDir\ff.exe" /END
nsDialogs::show
${NSD_KillTimer} myTimer
FunctionEnd
Page Custom myPage
Page InstFiles