Nsis mui tutorial

Source: Internet
Author: User
Tags droplist

NSIS 2.0 supports customized user interfaces. The so-called Modern UI (MUI) is an interface system that imitates the latest Windows interface style. MUI changes the NSIS script writing habits. It is expressed by NSIS macros, and macros are used to specify MUI attributes. Therefore, LicenseText, Icon, CheckBitmap, and InstallColors are meaningless in MUI.

MUI built-in Wizard Page
Wizard Page related to setup
MUI_PAGE_WELCOME: the welcome information is displayed on this Wizard Page.
MUI_PAGE_LICENSE text/rtf_file this wizard page displays the software authorization statement
MUI_PAGE_COMPONENTS the wizard page displays the installation component selection
MUI_PAGE_DIRECTORY the wizard page displays the select folder
MUI_PAGE_STARTMENU page_id variable this wizard page shows the Start Menu directory Selection
MUI_PAGE_INSTFILES the wizard page displays the installation progress
MUI_PAGE_FINISH The Wizard Page shows that the installation is complete.

Wizard Page related to the uninstall program
MUI_UNPAGE_WELCOME
MUI_UNPAGE_CONFIRM
MUI_UNPAGE_LICENSE text/rtf_file
MUI_UNPAGE_COMPONENTS
MUI_UNPAGE_DIRECTORY
MUI_UNPAGE_INSTFILES
MUI_UNPAGE_FINISH

The page property settings must be placed before the macro of the inserted page. For example:
Var PLUGINS_FOLDER
! Define MUI_DIRECTORYPAGE_VARIABLE $ PLUGINS_FOLDER
! Insertmacro MUI_PAGE_DIRECTORY
This nsi script stores the selected directory location on the directory selection page to the variable $ PLUGINS_FOLDER.

The following describes the attributes of the built-in wizard pages of MUI:
Applicable properties for all pages
MUI_PAGE_HEADER_TEXT text
Text displayed on the Wizard Page

MUI_PAGE_HEADER_SUBTEXT text
Text displayed on the Wizard Page. It is usually displayed under MUI_PAGE_HEADER_TEXT, indicating further explanation of MUI_PAGE_HEADER_TEXT.
Use macros to customize the InstallOptions interface! Insertmacro MUI_HEADER_TEXT "$ (TEXT_IO_TITLE)" $ (TEXT_IO_SUBTITLE) "provides similar functions.

Welcome Page attributes
MUI_WELCOMEPAGE_TITLE title
Title displayed on the welcome Wizard Page

MUI_WELCOMEPAGE_TITLE_3LINES
Space in the title Area

MUI_WELCOMEPAGE_TEXT text
Text displayed on the welcome Wizard Page. Use \ r \ n for line feed.
Generally, these attributes do not need to be specified, and the missing values are sufficient.

Software authorization page attributes
On the software authorization page, you can customize three methods for users to accept software authorization licenses: buttons, checkbox, and radio.
MUI_LICENSEPAGE_TEXT_TOP text
Text displayed on the top of the page

MUI_LICENSEPAGE_TEXT_BOTTOM text
Text displayed at the bottom of the page

MUI_LICENSEPAGE_BUTTON button_text
Button text

MUI_LICENSEPAGE_CHECKBOX
Define this macro to indicate that the user needs to check the checkbox to accept the software license

MUI_LICENSEPAGE_CHECKBOX_TEXT text
Text displayed next to the checkbox

MUI_LICENSEPAGE_RADIOBUTTONS
Define this macro to indicate that you need to select the corresponding radio box to accept or reject software licenses.

MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_ACCEPT text
Indicates accepted text displayed next to radio

MUI_LICENSEPAGE_RADIOBUTTONS_TEXT_DECLINE text
Drop text displayed next to radio

Select page properties for installation components

MUI_COMPONENTSPAGE_TEXT_TOP text
Text displayed on the top of the page

MUI_COMPONENTSPAGE_TEXT_COMPLIST text
Text displayed next to the component list

MUI_COMPONENTSPAGE_TEXT_INSTTYPE text
Text displayed next to the security type drop-down box

MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_TITLE text
Text displayed at the top of the description box

MUI_COMPONENTSPAGE_TEXT_DESCRIPTION_INFO text
Text displayed in the description box when no installation component is selected

Select page properties for installation directory

MUI_DIRECTORYPAGE_TEXT_TOP text
Text displayed on the top of the page

MUI_DIRECTORYPAGE_TEXT_DESTINATION text
Text displayed in the select box of the target directory

MUI_DIRECTORYPAGE_VARIABLE variable
Stores the variables in the selected directory. The default value is $ INSTDIR.

MUI_DIRECTORYPAGE_VERIFYONLEAVE
Verify the directory validity when you leave this page. Do not disable the "Next" button.

Start Menu directory selection page

The code for creating a shortcut should be placed between MUI_STARTMENU_WRITE_BEGIN and MUI_STARTMENU_WRITE_END. The example is as follows:
! Insertmacro MUI_STARTMENU_WRITE_BEGIN page_id
... Create shortcuts...
! Insertmacro MUI_STARTMENU_WRITE_END

The page_id here is the page on which you select to create a shortcut.

MUI_STARTMENUPAGE_TEXT_TOP text
Text displayed on the top of the page

MUI_STARTMENUPAGE_TEXT_CHECKBOX text
Text displayed next to the checkbox to prohibit creation of shortcuts

MUI_STARTMENUPAGE_DEFAULTFOLDER folder
Default Start Menu directory

MUI_STARTMENUPAGE_NODISABLE
Disable the checkbox used to prohibit creation of shortcuts

MUI_STARTMENUPAGE_REGISTRY_ROOT root
MUI_STARTMENUPAGE_REGISTRY_KEY key
MUI_STARTMENUPAGE_REGISTRY_VALUENAME value_name
These three keys and values are used to specify the keys and values set for the Start menu in the registry, and are used to record user preferences. It should be deleted during uninstallation.
To uninstall a program, you can use the macro MUI_STARTMENU_GETFOLDER to obtain the Start Menu directory. The following example shows how to delete the shortcut:
! Insertmacro MUI_STARTMENU_GETFOLDER page_id $ R0
Delete "$ SMPROGRAMS \ $ R0 \ Your Shortcut. lnk"

Installation progress page properties

MUI_INSTFILESPAGE_FINISHHEADER_TEXT text
The text on the installation progress page is displayed, but not on the end page MUI _ (UN) FINISHPAGE_NOAUTOCLOSE.

MUI_INSTFILESPAGE_FINISHHEADER_SUBTEXT text
On the installation progress page, further description of MUI_INSTFILESPAGE_FINISHHEADER_TEXT is provided. The end page is not MUI _ (UN) FINISHPAGE_NOAUTOCLOSE) and is not displayed.

MUI_INSTFILESPAGE_ABORTHEADER_TEXT text
The text on the installation progress page indicates that the installation process is terminated abnormally.

MUI_INSTFILESPAGE_ABORTHEADER_SUBTEXT text
Further description of MUI_INSTFILESPAGE_ABORTHEADER_TEXT

Complete page properties

On the completion page, you can run a program to open a file or website.

MUI_FINISHPAGE_TITLE title
Page title

MUI_FINISHPAGE_TITLE_3LINES
Additional spaces in the page title Area

MUI_FINISHPAGE_TEXT text
Text displayed on the completion page, line feed with \ r \ n

MUI_FINISHPAGE_TEXT_LARGE
If the checkbox is used, you need to set additional space for the checkpoints area.

MUI_FINISHPAGE_BUTTON text
Display text of the finish button

MUI_FINISHPAGE_TEXT_REBOOT text
Restart the text next to the operating system checkbox and use \ r \ n to wrap the text

MUI_FINISHPAGE_TEXT_REBOOTNOW text
Text displayed next to 'reboot now'

MUI_FINISHPAGE_TEXT_REBOOTLATER text
Text displayed next to 'reboot later'

MUI_FINISHPAGE_RUN exe_file
You can use checkbox to select the running application. If there is a space, no reference is required.

MUI_FINISHPAGE_RUN_TEXT text
Run text next to application checkbox

MUI_FINISHPAGE_RUN_PARAMETERS parameters
Parameters used to run the application. Double quotation marks ($ \) are required.

MUI_FINISHPAGE_RUN_NOTCHECKED
The checkbox of the running application is not selected.

MUI_FINISHPAGE_RUN_FUNCTION function_name
Specifies the nsi function to be executed after installation. Multiple applications can be run in this function.

MUI_FINISHPAGE_SHOWREADME file/url
You can use checkbox to select whether to view a file or website. If there is a space, no reference is required.

MUI_FINISHPAGE_SHOWREADME_TEXT text
Specify the display text next to 'show Readme 'checkbox

MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
The 'show Readme 'checkbox is not selected.

MUI_FINISHPAGE_SHOWREADME_FUNCTION function_name
Specifies the nsis function to be executed after installation. Multiple files or websites can be displayed in this function.

MUI_FINISHPAGE_LINK link_text
Text that can be clicked by the user on the hyperlink

MUI_FINISHPAGE_LINK_LOCATION file/url
Whether the user can view the website with a hyperlink. If there is a space, no reference is required.

MUI_FINISHPAGE_LINK_COLOR (color: RRGGBB hexadecimal)
The text color on the hyperlink. The default value is 000080.

MUI_FINISHPAGE_NOREBOOTSUPPORT
Disable operating system restart.

Unmount confirmation page properties

MUI_UNCONFIRMPAGE_TEXT_TOP text
Text displayed on the top of the page

MUI_UNCONFIRMPAGE_TEXT_LOCATION text
Text displayed next to uninstall location

InstallOptions and custom page
InstallOptions is an NSIS plug-in that allows installation developers to create custom wizard pages to obtain user input that is not provided on the built-in Wizard Page.

InstallOptions creates a dialog box embedded in the NSIS form. The InstallOptions control is described in the INI file. This file can be generated using a visualization tool. Hm nis edit is such a tool.

Structure of the INI file of the InstallOptions Control
The InstallOptions INI file contains a required segment. It contains the number of controls and the properties of the form. This article can also contain segments that describe specific spaces.
The required segment is Settings, which can contain the following content:
NumFields (required) number of controls contained in this dialog box
Title (optional) Title of a Windows form
CancelEnabled (optional) Whether to enable the Cancel button, 1: Yes, 0: No
CancelShow (optional) Whether to display the Cancel button, 1: Yes, 0: No
BackEnabled (optional) Whether to enable the Back button, 1: Yes, 0: No
Display text of the CancelButtonText (optional) Cancel button
Display text of NextButtonText (optional) Next button
Display text of BackButtonText (optional) Back button
Rect (optional)
RTL (optional)
State (output) This is not something you have to supply yourself but is set by InstallOptions, before calling your custom page validation function, to the field number of the custom Button control (or other control having the specified y flag) the user pressed, if any.

Each control segment is named in the "Field #" mode. The well number represents a number, starting from 1. Controls have the following attributes:

Type (required) controls include "Label", "Text", "Password", "Combobox", "DropList", "Listbox", "CheckBox ", "RadioButton", "FileRequest", "DirRequest" "Icon", "Bitmap", "GroupBox", "Link" or "Button ".

"Label" is used to display static text
"Text" and "Password" are similar to those in HTML to accept user input.
"Combobox" allows you to enter items that do not exist in the list. "Droplist" only supports the items specified in the list.
"Listbox" displays multiple options (you do not need to drop-down to view them) and allows multiple options
"CheckBox" "RadioButton" is similar to the corresponding control in Windows.
"FileRequest" displays an input box and a browse button. You can select a file in the file selection dialog box.
"DirRequest" is similar to "FileRequest", but only the directory is selected.
"Icon" display Icon
"Bitmap" display Bitmap
"GroupBox" display combo box
"Link" displays the hyperchain
"Button" Button

(Optional) for the checkbox, the radio button control is caption, The DirRequest control is the title of the browser dialog box, And the icons and bitmap controls are the path of the image file.

State (optional) control status, which can be read in the nsi script. For text controls, the state value is a string that you enter. For radio buttons and check boxes, the state is '0' or '1 '. The Status values of list boxes, combo boxes, and drop lists are selected. If there are multiple statuses, use the pipeline symbol '|' to separate them. Hyperlinks and button states are strings that can be executed with ShellExecute.

The options of ListItems (optional) combobox, droplist, or listbox are separated by the pipeline symbol '| '.
MaxLen (optional) maximum input length
MinLen (optional) minimum input length
ValidateText (optional) Verification text

Left
Right
Top
The coordinates of the Bottom (required) control are not important in the visual environment.
Filter (optional) specifies the file Filter of the "FileRequest" control, such as a text file | *. txt | program file | *. exe; *. com | all files | *.*

Root (optional) specifies the Root directory of the "DirRequest" Control
Flags (optional) specifies the modifier of the control. Multiple values are separated by the pipe sign '|' and cannot contain spaces. Valid values:
Value Meaning
REQ_SAVE: Convert the "FileRequest" control to the "Save as" dialog box
FILE_MUST_EXIST is used for the "FileRequest" control and specifies whether the selected file must exist.
FILE_EXPLORER is used for the "FileRequest" Control
FILE_HIDEREADONLY is used for the "FileRequest" control to hide "open read only" checkbox
WARN_IF_EXIST is used for the "FileRequest" control. A warning is displayed if the file already exists.
PATH_MUST_EXIST is used for the "FileRequest" control, specifying that the input path must exist
PROMPT_CREATE is used for the "FileRequest" control. A warning is displayed before creation if the file or path does not exist.
RIGHT is used for the "Checkbox" and Radiobutton "controls. It specifies that the text appears on the left and is rarely used.
MULTISELECT is used for the "Listbox" control to allow multiple selections
EXTENDEDSELCT is used for the "Listbox" control to allow multiple selections
RESIZETOFIT is used for the "Bitmap" control to expand the image size to the control.
GROUP multiple controls. This flag is placed on the first control in the same GROUP.
NOTABSTOP disable the tab key from focusing on the Control
DISABLED Control
ONLY_NUMBERS is used for the "Text" control, Forces the user to enter only numbers into the edit box.
MULTILINE is used for the "Text" control, allowing multiple lines of input
WANTRETURN is used for the "Text" control and allows multiple lines of input. It is required to insert a carriage return when you press Enter.
NOWORDWRAP is used for the "Text" control. multiple lines of input are allowed to disable word-wrap.
HSCROLL displays the horizontal scroll bar
VSCROLL displays the scroll bar in the vertical direction
READONLY is used for the "Text" control to make the Text input box read-only
Policy is used for the "Button", "Link", "CheckBox", "RadioButton", "ListBox", and "DropList" controls. Trigger the InstallOptions event and call the validation/leave method on the custom page.
TxtColor (optional) is used for the "Link" control and specifies the foreground color of the text. The format is 0 xBBRRGG (hexadecimal)

To use the custom Wizard Page, follow these steps:
1. Design and customize the Wizard Page interface to generate the interface description INI file. You can use the visual tool hm nis Edit to simplify development.
2. Compile the nsi script:
First, if you use lzma, gzip, and other compression algorithms, You need to reserve the ini File on the custom interface before all File commands: ReserveFile ". ini ".
Then, use the macro in the. onInit method! Insertmacro MUI_INSTALLOPTIONS_EXTRACT ". ini ".
Then, compile the display function of the custom dialog box.
Finally, use the Page command to insert the Wizard Page at the appropriate location.

Examples of functions displayed in the Custom dialog box:
Function setChooseBuildArea
! Insertmacro MUI_HEADER_TEXT "select build directory" "select build directory"
! Insertmacro MUI_INSTALLOPTIONS_WRITE "buildarea. ini" "Field 2" "State" "$ INSTDIR \ buildarea"
! Insertmacro MUI_INSTALLOPTIONS_DISPLAY "buildarea. ini"
FunctionEnd
The first line of the function sets the text on the Wizard Page. The second line sets the State of the second control on the Wizard Page to "$ INSTDIR \ buildarea ", that is, set the default value of the control; the third line of code Display dialog box.
The following code inserts a Wizard Page using the Page command:
Page custom setChooseBuildArea "" -- select build directory"
The command accepts three parameters. The first two are the display and exit functions on the page, and the third is the text displayed in the title bar.

If nsi variables are stored in strings, only 1024 is saved by default. For complex Java applications, the length of the Classpath command line usually exceeds 1024. In this case, the nsi variable must support a string length greater than 1024. There are two ways to solve this problem. One is to download special Builds at http: // nsis.sourceforge.net/download/specialbuilds/. currently, a build called Large strings can store 8192 characters; the other is to manually compile the NSIS source code and add the required options.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.