[英]How do I capture the results of a YESNOCANCEL MessageBox without gotos/labels in NSIS installer scripting?
我想知道如何在NSIS安装程序脚本中使用YESNOCANCEL MessageBox和LogicLib.nsh中的IF逻辑,以避免使用标签和gotos。
有没有办法在某种变量中捕获MessageBox的结果?
此外,我知道有比NSIS更好的东西,但在这一点上使用其他东西不是可能的。 =(
请注意以下代码中的{WHAT GOES HERE??}
。 如果这只是一个If ... Else ......它会正常工作。
谢谢您的帮助
${If} ${Cmd} `MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION
"PROGRAM X is already installed. Click YES to remove the installed version
found in C:\Program Files(x86). Click NO to skip uninstall and choose a
different install location (not recommended) or CANCEL to terminate
the installer." IDYES`
MessageBox MB_OK "Yes was clicked"
${ElseIf} {WHAT GOES HERE??}
MessageBox MB_OK "No was clicked"
${Else}
MessageBox MB_OK "Cancel was clicked"
${EndIf}
更新 :我也找到了这个例子,但我不确定${||}
是做什么的,或者它对我有什么帮助。
; ifcmd..||..| and if/unless cmd
StrCpy $R2 ""
${IfCmd} MessageBox MB_YESNO "Please click Yes" IDYES ${||} StrCpy $R2 $R2A ${|}
${Unless} ${Cmd} `MessageBox MB_YESNO|MB_DEFBUTTON2 "Please click No" IDYES`
StrCpy $R2 $R2B
${EndUnless}
${If} $R2 == "AB"
DetailPrint "PASSED IfCmd/If Cmd test"
${Else}
DetailPrint "FAILED IfCmd/If Cmd test"
${EndIf}
以${|}
结尾的行表示如果条件为真,则执行单个指令的if块:
${IfThen} $Instdir == $Temp ${|} MessageBox mb_ok "$$InstDir equals $$Temp" ${|}
这只是简写语法:
${If} $Instdir == $Temp
MessageBox mb_ok "$$InstDir equals $$Temp"
${EndIf}
IfCmd宏在内部使用${IfThen} ${Cmd}
, ${||}
是一个黑客来结束由IfCmd启动的字符串引用,所以:
${IfCmd} MessageBox MB_YESNO "click yes" IDYES ${||} MessageBox mb_ok choice=IDYES ${|}
是简写:
${If} ${Cmd} 'MessageBox MB_YESNO "yes" IDYES' ;notice the quotes here
MessageBox mb_ok choice=IDYES
${EndIf}
你甚至可以混合ifthen和标签,但这是丑陋的恕我直言:
StrCpy $0 "Cancel"
${IfCmd} MessageBox MB_YESNOCANCEL "Mr. Powers?" IDYES yes IDNO ${||} StrCpy $0 "NO?!" ${|}
MessageBox mb_iconstop $0 ;Cancel or NO
goto end
yes:
MessageBox mb_ok "Yeah baby yeah!"
end:
(最好只使用MessageBox for YESNOCANCEL和ABORTRETRYIGNORE,对于YESNO,OKCANCEL等,为两个选项执行不同的代码,使用$ {If} $ {Cmd}'MessageBox ..'.. $ {Else} .. $ {EndIf}语法)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.