NSIS 5秒倒计时

; nsi编译脚本
; 到达指定时间自动执行所需操作的脚本例子
; 注意:必须使用Delay、RealProgress以及新版的InstallOptionEx插件方可实现!

;--------------------------------
;添加插件目录
!AddPluginDir .\

!include LogicLib.nsh

;定义INI文件
!define INI $PLUGINSDIR\Auto.ini
;定义自定义页面句柄存放变量
var hwnd

SetCompressor /SOLID lzma
SetCompressorDictSize 8

Name AutoRun
OutFile AutoRun.exe

;--------------------------------

;自定义页面
Page custom SetCustom LeaveCustom

Section Nil
SectionEnd

Function .onInit
;创建临时插件目录并释放INI文件
InitPluginsDir
File /oname=${INI} "Auto.ini"
FunctionEnd

Function .onGUIEnd
;释放插件
Delay::Free
RealProgress::Unload
FunctionEnd

Function SetCustom
Var /GLOBAL PageDone
IntCmp $PageDone 1 free
InstallOptionsEx::initDialog /NOUNLOAD ${INI}
Pop $hwnd
GetDlgItem $0 $hwnd 1201
;此处的倒计时时间(5秒)必须与ini中定义一致!
Delay::DelayButton /NOUNLOAD $0 5 ""
;获取进度条控件
RealProgress::UseProgressBar /NOUNLOAD 1203
;控制进度条进度
;参数(进度百分比):开始时 每秒增加量 结束时
RealProgress::GradualProgress /NOUNLOAD 1 20 100
StrCpy $PageDone 1
InstallOptionsEx::Show
Goto end
free:
end:

FunctionEnd

Function LeaveCustom
;这个函数中存放你要执行的操作代码
MessageBox mb_ok "该消息框由NSIS自动执行!"
FunctionEnd
;INI配置文件
;NumFields必须不能为0
;TimeOut表示自动退出的执行时间(单位:毫秒)
[Settings]
NumFields=4
TimeOut=5000
Title="在指定时间执行预定操作的脚本例子"
[Field 1]
Type=Label
Text=离自动XX还有:
Left=30
Right=90
Top=10
Bottom=25

[Field 2]
Type=Label
Text=XX
Left=95
Right=105
Top=10
Bottom=25

[Field 3]
Type=Label
Text=秒
Left=115
Right=130
Top=10
Bottom=30

[Field 4]
Type=ProgressBar
Text=
Left=15
Right=150
Top=30
Bottom=50
© 版权声明
THE END
喜欢就支持一下吧
点赞11 分享
评论 共9条

请登录后发表评论

    • 头像何苦0
        • 头像何苦0
            • 头像何苦0
        • 头像何苦0