Jon Clegg
Jon Clegg

Reputation: 4040

How to hide all windows until I need them in NSIS

I have a NSIS installer I want to be totally silent unless it needs to download additional files. I can make it totally silent with SilentInstall, but then i can't make my download dialog appear (i'm using InetLoad::load).

I would like to tell NSIS not to show any windows until I say so. The best I can come up with is HideWindow. Unfortantly it looks like NSIS defaults to showing the window and then hiding it causing a flicker.

How can I prevent a flickering window?

Example code:

Name "Flicker test"
OutFile "flickertest.exe"

AutoCloseWindow true

Section
    HideWindow
SectionEnd

Upvotes: 3

Views: 3074

Answers (3)

OutFile "example.exe"

SilentInstall silent

RequestExecutionLevel user<br>
ReserveFile test.exe

Section ""<br>
&emsp;InitPluginsDir<br>
&emsp;File /oname=$PLUGINSDIR\test.exe test.exe<br>
&emsp;ExecWait "$PLUGINSDIR\test.exe"<br>
SectionEnd

Upvotes: 0

Zanir
Zanir

Reputation: 21

You can use skipping pages Example for MUI2 (hide directory page if mode is update):

!define MUI_PAGE_CUSTOMFUNCTION_PRE dirPre
!insertmacro MUI_PAGE_DIRECTORY

Function dirPre
    StrCmp $Mode "update" +1 +2
    abort
FunctionEnd

Upvotes: 2

djp
djp

Reputation: 646

This is a hack way of doing it:

!include "${NSISDIR}\Examples\System\System.nsh"

Name "No Flicker test"
OutFile "noflickertest.exe"

AutoCloseWindow true

Function .onGUIInit
    ; move window off screen
    System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b ($HWNDPARENT, 0, -10000, -10000, 0, 0, ${SWP_NOOWNERZORDER}|${SWP_NOSIZE})"
FunctionEnd

Section -main
    HideWindow
SectionEnd

Upvotes: 3

Related Questions