Roberto Aloi
Roberto Aloi

Reputation: 30995

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

Upvotes: 1

Views: 7228

Answers (1)

Anders
Anders

Reputation: 101764

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...

Upvotes: 3

Related Questions