预检查 NSIS 许可页面
NSIS license page prechecked
我在 NSIS 脚本中有以下代码...
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "eula.txt"
...而且效果很好。正如预期的那样,用户需要检查 "I accept..." checkbox
,然后启用安装 button
。
我想简化该过程,以便默认选中 checkbox
并启用安装 button
,用户需要做的就是安装或取消。
谢谢大家
我很幸运,能够将几个地方的代码放在一起。
以下有效,但我真的不知道为什么 NSIS-wise,我一点也不喜欢。如果有人能分解一下,我真的非常感谢。
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_PAGE_CUSTOMFUNCTION_SHOW licshow
!insertmacro MUI_PAGE_LICENSE "eula.txt"
Function licshow
; Check it
FindWindow [=10=] "#32770" "" $HWNDPARENT
GetDlgItem [=10=] [=10=] 0x40A
SendMessage [=10=] ${BM_SETCHECK} 1 0
; Enable button
GetDlgItem [=10=] $hwndparent 1
EnableWindow [=10=] 1
FunctionEnd
!define MUI_LICENSEPAGE_CHECKBOX ; Tell MUI you want the checkbox version of the license page
!define MUI_PAGE_CUSTOMFUNCTION_SHOW licshow ; Tell MUI to call a function before the page is displayed
!insertmacro MUI_PAGE_LICENSE "eula.txt" ; Adds the page
Function licshow ; Function to be called before the page is displayed
; Check it
FindWindow [=10=] "#32770" "" $HWNDPARENT ; Find the inner dialog (See attached picture)
GetDlgItem [=10=] [=10=] 0x40A ; Find the checkbox control
SendMessage [=10=] ${BM_SETCHECK} 1 0 ; Check the checkbox
; Enable button
GetDlgItem [=10=] $hwndparent 1 ; Find the Install/Next button
EnableWindow [=10=] 1 ; Enable the button
FunctionEnd
最后的 GetDlgItem+EnableWindow 命令可以替换为 SendMessage $HWNDPARENT ${WM_COMMAND} 0x40A 0
以模拟用户点击并导致 NSIS 内部处理启用按钮。
我在 NSIS 脚本中有以下代码...
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE "eula.txt"
...而且效果很好。正如预期的那样,用户需要检查 "I accept..." checkbox
,然后启用安装 button
。
我想简化该过程,以便默认选中 checkbox
并启用安装 button
,用户需要做的就是安装或取消。
谢谢大家
我很幸运,能够将几个地方的代码放在一起。
以下有效,但我真的不知道为什么 NSIS-wise,我一点也不喜欢。如果有人能分解一下,我真的非常感谢。
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_PAGE_CUSTOMFUNCTION_SHOW licshow
!insertmacro MUI_PAGE_LICENSE "eula.txt"
Function licshow
; Check it
FindWindow [=10=] "#32770" "" $HWNDPARENT
GetDlgItem [=10=] [=10=] 0x40A
SendMessage [=10=] ${BM_SETCHECK} 1 0
; Enable button
GetDlgItem [=10=] $hwndparent 1
EnableWindow [=10=] 1
FunctionEnd
!define MUI_LICENSEPAGE_CHECKBOX ; Tell MUI you want the checkbox version of the license page
!define MUI_PAGE_CUSTOMFUNCTION_SHOW licshow ; Tell MUI to call a function before the page is displayed
!insertmacro MUI_PAGE_LICENSE "eula.txt" ; Adds the page
Function licshow ; Function to be called before the page is displayed
; Check it
FindWindow [=10=] "#32770" "" $HWNDPARENT ; Find the inner dialog (See attached picture)
GetDlgItem [=10=] [=10=] 0x40A ; Find the checkbox control
SendMessage [=10=] ${BM_SETCHECK} 1 0 ; Check the checkbox
; Enable button
GetDlgItem [=10=] $hwndparent 1 ; Find the Install/Next button
EnableWindow [=10=] 1 ; Enable the button
FunctionEnd
最后的 GetDlgItem+EnableWindow 命令可以替换为 SendMessage $HWNDPARENT ${WM_COMMAND} 0x40A 0
以模拟用户点击并导致 NSIS 内部处理启用按钮。