Search code examples
applescriptnsis

Simple Input Dialog in NSIS


In my NSIS installer, I want to display an input dialog (text + textbox) to the user and to retrieve the result of that input, so that I can use it later in the NSIS script.

I've found this reference page:

http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.4.15

But I couldn't find any reference to a textbox.

If it helps, what I need is the NSIS equivalent of the following AppleScript code:

display dialog "Insert value:" default answer ""
set value to text returned of result

Solution

  • Use nsDialogs or InstallOptions (both part of NSIS) to create a custom page:

    Outfile test.exe
    Requestexecutionlevel user
    
    !include nsDialogs.nsh
    
    Page Custom mypagecreate mypageleave
    Page Instfiles
    
    Function mypagecreate
    Var /Global MyTextbox
    nsDialogs::Create /NOUNLOAD 1018
    Pop $0
    ${NSD_CreateText} 10% 20u 80% 12u "Hello World"
    Pop $MyTextbox
    nsDialogs::Show
    FunctionEnd
    
    Function mypageleave
    ${NSD_GetText} $MyTextbox $0
    MessageBox mb_ok $0
    Abort ;Don't move to next page (If the input was invalid etc)
    FunctionEnd
    
    Section
    SectionEnd
    

    Popup dialogs are not really supported but it can be done with this plugin...