1

後で構成ファイルに書き込むために使用するユーザー入力を収集することを目標に、 NSIS nsDialog チュートリアルに従っています。NSISEclipse プラグインは、MUI2 テンプレートを生成しました。これで作業を開始し、ファイルを正常にインストールできました。

nsDialog チュートリアルを使用して、必要な場所に正確に出力されるダイアログを生成しましたが、何らかの理由で「戻る/次へ/キャンセル」ボタンがすべて灰色になっています。これらのボタンを有効/無効にするように指示されている nsDialog ドキュメントの場所がわかりません。

これが私のコードです:

Var Dialog
Var Label
Var MyTextBox
Section configLocationDialog
   nsDialogs::Create 1018
   Pop $Dialog
   ${If} $Dialog == error
       Abort
   ${EndIf}

   ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
   Pop $Label

   ${NSD_CreateText} 10% 20u 80% 12u "Hello World"
   Pop $MyTextbox

   nsDialogs::Show
SectionEnd

そして、一度表示されたダイアログ:

ボタンが無効になっているダイアログ

NSIS に戻る/次へ/キャンセルを許可するには、何を変更する必要がありますか?

EDITより多くのコードが求められました。こちらが現在の全容です。

# Auto-generated by EclipseNSIS Script Wizard
# Dec 19, 2013 3:48:34 PM
Name SecureKeypad

# General Symbol Definitions
!define REGKEY "SOFTWARE\$(^Name)"
!define VERSION 1.0.0
!define COMPANY **COMPANY**
!define URL http://www.**COMPANY**.com

# MultiUser Symbol Definitions
!define MULTIUSER_EXECUTIONLEVEL Standard
!define MULTIUSER_INSTALLMODE_COMMANDLINE
!define MULTIUSER_INSTALLMODE_INSTDIR $PROGRAMFILES\SecureKeypad
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_KEY "${REGKEY}"
!define MULTIUSER_INSTALLMODE_INSTDIR_REGISTRY_VALUE "Path"

# MUI Symbol Definitions
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install-colorful.ico"
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM
!define MUI_STARTMENUPAGE_NODISABLE
!define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY}
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup
!define MUI_STARTMENUPAGE_DEFAULTFOLDER SecureKeypad
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall-colorful.ico"
!define MUI_UNFINISHPAGE_NOAUTOCLOSE

# Included files
#!include MultiUser.nsh
!include LogicLib.nsh
!include nsDialogs.nsh
!include AdvReplaceInFile.nsh
!include Sections.nsh
!include MUI2.nsh

# Variables
Var StartMenuGroup

# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

# Installer languages
!insertmacro MUI_LANGUAGE English

# Installer attributes
OutFile setup.exe
CRCCheck on
InstallDir $PROGRAMFILES\${COMPANY}\SecureKeypad
XPStyle on
ShowInstDetails show
VIProductVersion 1.0.0.0
VIAddVersionKey ProductName SecureKeypad
VIAddVersionKey ProductVersion "${VERSION}"
VIAddVersionKey CompanyName "${COMPANY}"
VIAddVersionKey CompanyWebsite "${URL}"
VIAddVersionKey FileVersion "${VERSION}"
VIAddVersionKey FileDescription ""
VIAddVersionKey LegalCopyright ""
InstallDirRegKey HKLM "${REGKEY}" Path
ShowUninstDetails show

# Input dialogs
Var Dialog
Var Label
Var MyTextbox
#Page custom configLocationDialog configLocationDialogLeave
#Page custom doConfiguration
Section configLocationDialog
    nsDialogs::Create 1018
    Pop $Dialog
    ${If} $Dialog == error
        Abort
    ${EndIf}

    GetFunctionAddress $0 "configLocationDialogLeave"
    nsDialogs::OnBack $Dialog $0
    #nsDialogs::OnNext $Dialog

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 10% 20u 80% 12u "Hello World"
    Pop $MyTextbox

    nsDialogs::Show
SectionEnd

Function configLocationDialogLeave
    ${NSD_GetText} $MyTextbox $0
    MessageBox mb_ok $0
FunctionEnd

# Installer sections
Section -Main SEC0000
    SetOutPath $INSTDIR
    SetOverwrite on
    File installable-content\CYBSSecurity.dll
    File installable-content\SecureKeypad.exe
    File installable-content\SecureKeypad.exe.config
    File installable-content\SecureKeypad.config
    File installable-content\SecureKeypad.frmSecureKeypad.resources
    WriteRegStr HKLM "${REGKEY}\Components" Main 1

    !insertmacro AdvReplaceInFile $INSTDIR\SecureKeypad.exe.config "@@configFile@@" $INSTDIR
SectionEnd

Section -post SEC0001
    WriteRegStr HKLM "${REGKEY}" Path $INSTDIR
    SetOutPath $INSTDIR
    WriteUninstaller $INSTDIR\uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
    SetOutPath $SMPROGRAMS\$StartMenuGroup
    CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe
    !insertmacro MUI_STARTMENU_WRITE_END
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" Publisher "${COMPANY}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" URLInfoAbout "${URL}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayIcon $INSTDIR\uninstall.exe
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1
    WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1
SectionEnd

# Macro for selecting uninstaller sections
!macro SELECT_UNSECTION SECTION_NAME UNSECTION_ID
    Push $R0
    ReadRegStr $R0 HKLM "${REGKEY}\Components" "${SECTION_NAME}"
    StrCmp $R0 1 0 next${UNSECTION_ID}
    !insertmacro SelectSection "${UNSECTION_ID}"
    GoTo done${UNSECTION_ID}
next${UNSECTION_ID}:
    !insertmacro UnselectSection "${UNSECTION_ID}"
done${UNSECTION_ID}:
    Pop $R0
!macroend

# Uninstaller sections
Section /o -un.Main UNSEC0000
    Delete /REBOOTOK $INSTDIR\SecureKeypad.frmSecureKeypad.resources
    Delete /REBOOTOK $INSTDIR\SecureKeypad.exe.config
    Delete /REBOOTOK $INSTDIR\SecureKeypad.exe
    Delete /REBOOTOK $INSTDIR\<sensored>.dll
    DeleteRegValue HKLM "${REGKEY}\Components" Main
SectionEnd

Section -un.post UNSEC0001
    DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)"
    Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk"
    Delete /REBOOTOK $INSTDIR\uninstall.exe
    DeleteRegValue HKLM "${REGKEY}" StartMenuGroup
    DeleteRegValue HKLM "${REGKEY}" Path
    DeleteRegKey /IfEmpty HKLM "${REGKEY}\Components"
    DeleteRegKey /IfEmpty HKLM "${REGKEY}"
    RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup
    RmDir /REBOOTOK $INSTDIR
SectionEnd

# Installer functions
Function .onInit
    InitPluginsDir
FunctionEnd

# Uninstaller functions
Function un.onInit
    !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuGroup
    !insertmacro SELECT_UNSECTION Main ${UNSEC0000}
FunctionEnd
4

3 に答える 3

1

セクション内での nsDialogs::Create/Show の呼び出しは有効ではありません。カスタム ページの create コールバック関数でのみ呼び出すことができます。

ページの後に一部のボタンが無効になりinstfilesます (既にインストールされているため、キャンセルまたは戻ることはできません) が、これは nsDialogs ではなく、NSIS 自体によって行われます...

于 2013-12-20T19:36:27.007 に答える
1

への呼び出しをセクションに入れるとnsDialogs:Create、インストーラーがファイルなどをインストールするときに実行されます。その状態では、インストーラーのページをナビゲートし続けることができず、スタックしてしまいます。

インストーラーの最後にカスタム ページが実行されているという通知は、間違った方法として却下するのではなく、実際に修正しようとする必要があるものです (それが唯一の方法です)。NSIS スクリプトは、多くの点で非常に単純です。たとえば、ページは宣言された順序で読み込まれます。MUI_PAGE_WELCOMEしたがって、 wantを宣言するMUI_PAGE_DIRECTORYと、他のものもそれらの順序を設定します。

# Installer pages
!insertmacro MUI_PAGE_WELCOME                                 # First page
!insertmacro MUI_PAGE_DIRECTORY                               # Second page
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup   # Third page
!insertmacro MUI_PAGE_INSTFILES                               # Etc
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

したがって、すべてのコードをまとめて、それを処理する関数と一緒にカスタム ページを追加しようとすると、間違いなくその順序で最後のページになります。

# Installer pages
!insertmacro MUI_PAGE_WELCOME                                 # First page
!insertmacro MUI_PAGE_DIRECTORY                               # Second page
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup   # Third page

...

# Input dialogs
Var Dialog
Var Label
Var MyTextbox
Page custom configLocationDialog configLocationDialogLeave    # Last page
Section configLocationDialog
  nsDialogs::Create 1018
  Pop $Dialog

これを説明するために、私はあなたのコードを取り、それを基本的にあなたが望むページに落とし込みました.

    # Included files
!include LogicLib.nsh
!include nsDialogs.nsh
!include Sections.nsh
!include MUI2.nsh

# Installer pages
!insertmacro MUI_PAGE_WELCOME                                 # First page
Page custom configLocationDialog configLocationDialogLeave    # Second page!
!insertmacro MUI_PAGE_FINISH                                  # Last page

# Installer languages
!insertmacro MUI_LANGUAGE English

# Input dialogs
Var Dialog
Var Label
Var MyTextbox

Function configLocationDialog
    nsDialogs::Create 1018
    Pop $Dialog
    ${If} $Dialog == error
    Abort
    ${EndIf}

    GetFunctionAddress $0 "configLocationDialogLeave"
    nsDialogs::OnBack $Dialog $0

    ${NSD_CreateLabel} 0 0 100% 12u "Hello, welcome to nsDialogs!"
    Pop $Label

    ${NSD_CreateText} 10% 20u 80% 12u "Hello World"
    Pop $MyTextbox

    nsDialogs::Show
FunctionEnd

Function configLocationDialogLeave
    ${NSD_GetText} $MyTextbox $0
    MessageBox mb_ok $0
FunctionEnd

Section -Main SEC0000

SectionEnd
于 2013-12-21T07:49:46.160 に答える