Archive for category: NSIS

TIL: Some NSIS utility functions

11 Mar
March 11, 2011
  • To trim a string use:
1
${WordReplace} $target " " "" "{}" $output

 

  • To get day/time info use:
1
${GetTime} "" "L" $Day $Month $Year $DayOfWeek $Hour $Minute $Second

 

  • To check a string for invalid characters you can use ${StrFilter}

 

NSIS trivia

09 Mar
March 9, 2011

Today I learned:

  • Modern UI dialogs are 140×300 pixels
  • nsDialogs::create 1018 creates a standard dialog according to the docs for NSDialogs, but most code uses 1044 instead (todo: investigate difference)
  • The Modern UI also has control 1040 for the welcome and the finish page.

NSIS Section flag tests

09 Mar
March 9, 2011

Today I learned:

[sourcecode language=”Python”]
SectionGetFlags ${SEC_AI}      $0
${If} $0 == ${SF_SELECTED}
[/sourcecode]

I was using the above code and getting inconsistent behavior. Turns out ${SF_SELECTED} is defined in sections.nsh bitmask style. The statement above ONLY works for a section that is selected and has no other attributes set. A read-only section that is selected, for example, will be set to “17” — 1 (selected) + 16 (readonly). Turns out that LogicLib has a way to make life easier:

[sourcecode language=”python”]
${If} ${SectionIsSelected} ${SEC_AI}
[/sourcecode]