脚本:按下自定义页面上的不同按钮显示不同的自定义页面

优质
小牛编辑
131浏览
2023-12-01

引用EAVSet.nsi的内容:

!define PRODUCT_NAME "ESET NOD32 Antivirus"
SetCompressor /SOLID lzma
SetCompressorDictSize 32

!include "MUI.nsh"
!include "UsefulLib.nsh"

!define MUI_ABORTWARNING
!define MUI_ICON "EAV.ico"
!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "header.bmp"
!define MUI_HEADERIMAGE_RIGHT

page custom io1 leave
page custom io2
!insertmacro MUI_PAGE_INSTFILES

!insertmacro MUI_LANGUAGE "SimpChinese"

!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS
ReserveFile "io1.ini"
ReserveFile "header.bmp"
ReserveFile "io2.ini"
ReserveFile "repair.ico"
ReserveFile "remove.ico"

Name "${PRODUCT_NAME}"
OutFile "EAVSet.exe"
InstallDir "$EXEDIR"
SetFont "Tahoma" 8
BrandingText "$\r"

Var Check
Section
	StrCmp $Check "fix" 0 +2
	Call inst
	StrCmp $Check "del" 0 +2
	Call uninst
SectionEnd

Function .onInit
;IfFileExists "$EXEDIR\egui.exe" +3
;  MessageBox MB_OK|MB_ICONEXCLAMATION "请把本程序放在 ${PRODUCT_NAME} 安装目录下运行!"
;  Quit
	!insertmacro MUI_INSTALLOPTIONS_EXTRACT "io1.ini"
	!insertmacro MUI_INSTALLOPTIONS_EXTRACT "io2.ini"
	!insertmacro MUI_INSTALLOPTIONS_EXTRACT "repair.ico"
	!insertmacro MUI_INSTALLOPTIONS_EXTRACT "remove.ico"
	!insertmacro MUI_INSTALLOPTIONS_WRITE "io1.ini" "Field 1" "Text" "$PLUGINSDIR\repair.ico"
	!insertmacro MUI_INSTALLOPTIONS_WRITE "io1.ini" "Field 3" "Text" "$PLUGINSDIR\remove.ico"
FunctionEnd

Function io1
	Push $R1
	Push $R2
	GetDlgItem $R1 $HWNDPARENT 1
	EnableWindow $R1 0
	!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "io1.ini"
	!insertmacro MUI_INSTALLOPTIONS_READ $R1 "io1.ini" "Field 2" "HWND"
	SendMessage $R1 ${WM_SETFOCUS} 0 0    ;设置焦点
	SendMessage $R1 ${BN_SETFOCUS} 1 0    ;通知已设置焦点
	SendMessage $R1 ${BM_SETSTYLE} 0x00000001 0x1
	!insertmacro MUI_INSTALLOPTIONS_READ $R1 "io1.ini" "Field 5" "HWND"
	CreateFont $R2 "$(^Font)" "$(^FontSize)" "700"
	SendMessage $R1 ${WM_SETFONT} $R2 0
	!insertmacro MUI_INSTALLOPTIONS_READ $R1 "io1.ini" "Field 7" "HWND"
	SendMessage $R1 ${WM_SETFONT} $R2 0
	!insertmacro MUI_HEADER_TEXT "修改、修复或删除安装" "选择您想执行的操作。"
	!insertmacro MUI_INSTALLOPTIONS_SHOW
	Pop $R2
	Pop $R1
FunctionEnd

Function leave
	!insertmacro MUI_INSTALLOPTIONS_READ $0 "io1.ini" "Settings" "State"
	${Switch} $0
		${Default}
			Abort
		${Case} 2
			StrCpy $Check "fix"
			!insertmacro MUI_INSTALLOPTIONS_WRITE "io2.ini" "Field 1" "Text" "单击“修复”来修复 ESET NOD32 Antivirus的安装。如果您想复查或更改您的安装设置,请单击“上一步”。单击“取消”可退出向导。"
			${Break}
		${Case} 4
			StrCpy $Check "del"
			!insertmacro MUI_INSTALLOPTIONS_WRITE "io2.ini" "Field 1" "Text" "单击“删除”来从您的计算机删除 ESET NOD32 Antivirus。如果您想复查或更改您的安装设置,请单击“上一步”。单击“取消”可退出向导。"
	${EndSwitch}
FunctionEnd

!macro MY_INSTALLOPTIONS str ht1 ht2
	!insertmacro MUI_INSTALLOPTIONS_INITDIALOG "io2.ini"
	GetDlgItem $R1 $HWNDPARENT 1
	SendMessage $R1 ${WM_SETTEXT} 0 "STR:${str}"
	!insertmacro MUI_HEADER_TEXT "${ht1}" "${ht2}"
	!insertmacro MUI_INSTALLOPTIONS_SHOW
!macroend

Function io2
	GetDlgItem $R1 $HWNDPARENT 1
	ShowWindow $R1 ${SW_SHOW}
	StrCmp $Check "fix" 0 +2
	!insertmacro MY_INSTALLOPTIONS "修复(&R)" "修复 ESET NOD32 Antivirus" "安装向导准备开始修复 ESET NOD32 Antivirus。"
	StrCmp $Check "del" 0 +2
	!insertmacro MY_INSTALLOPTIONS "删除(&R)" "删除 ESET NOD32 Antivirus" "您已选择从您的计算机删除程序。"
FunctionEnd

Function inst
	;在这里放上绿化的代码
	;....................
	HideWindow
	MessageBox MB_OK|MB_ICONINFORMATION "${PRODUCT_NAME} 已修复成功!"
	Quit
FunctionEnd

Function uninst
	;在这里放上卸载的代码
	;....................
	HideWindow
	MessageBox MB_YESNO|MB_TOPMOST|MB_ICONQUESTION  "必须重启计算机才能完成卸载,是否立即重启计算机?" IDNO +2
	Reboot
	Quit
FunctionEnd

点击另存资源文件