Old 11th March 2016, 10:54   #1
Carl_Zeiß
Junior Member
 
Join Date: Feb 2016
Posts: 5
Start Application after Install

My installer allows to install a couple of applications.
at FINISHPAGE i want a checkbox to start a specific application (!define MUI_FINISHPAGE_RUN), but hide the checkbox if the user has unchecked it on componentspage. how can i do this with mui2?

Last edited by Carl_Zeiß; 11th March 2016 at 12:29.
Carl_Zeiß is offline   Reply With Quote
Old 11th March 2016, 12:16   #2
stass
Senior Member
 
Join Date: Nov 2012
Posts: 146
!include MUI2.nsh
!include Logiclib.nsh

!define MUI_PAGE_CUSTOMFUNCTION_LEAVE CompLeave
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT " RunFunction"
!define MUI_FINISHPAGE_RUN_FUNCTION "RunFunction"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW CustomFinish
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE FinishLeave
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

var Checkbox1
var Checkbox2
var Checkbox3

Section "1" 1
SectionEnd

Section "2" 2
SectionEnd

Section "3" 3
SectionEnd

Function CompLeave
${If} ${SectionIsSelected} ${1}
StrCpy $R1 1
${EndIf}

${If} ${SectionIsSelected} ${2}
StrCpy $R2 1
${EndIf}

${If} ${SectionIsSelected} ${3}
StrCpy $R3 1
${EndIf}
FunctionEnd

Function CustomFinish
${NSD_CreateCheckbox} 120u 110u 100% 10u " Checkbox 1"
Pop $Checkbox1
${If} $R1 == 1
${NSD_SetState} $Checkbox1 1
${EndIf}
SetCtlColors $Checkbox1 "" "ffffff"

${NSD_CreateCheckbox} 120u 130u 100% 10u " Checkbox 2"
Pop $Checkbox2
${If} $R2 == 1
${NSD_SetState} $Checkbox2 1
${EndIf}
SetCtlColors $Checkbox2 "" "ffffff"

${NSD_CreateCheckbox} 120u 150u 100% 10u " Checkbox 3"
Pop $Checkbox3
${If} $R3 == 1
${NSD_SetState} $Checkbox3 1
${EndIf}
SetCtlColors $Checkbox3 "" "ffffff"
FunctionEnd

Function FinishLeave
${NSD_GetState} $Checkbox1 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox1 - ON"
${EndIf}

${NSD_GetState} $Checkbox2 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox2 - ON"
${EndIf}

${NSD_GetState} $Checkbox3 $0
${If} $0 <> 0
MessageBox mb_ok "Checkbox3 - ON"
${EndIf}
FunctionEnd

Function RunFunction
MessageBox mb_ok "RunFunction"
FunctionEnd
stass is offline   Reply With Quote
Old 13th March 2016, 11:59   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,263
All you have to do is to detect if the section is unchecked and if it is you modify the finish page. IMHO it would be enough to just uncheck the checkbox but my example also hides it because that is what you requested:

PHP Code:
!include MUI2.nsh
!include Logiclib.nsh
!include Sections.nsh

!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!define MUI_FINISHPAGE_RUN "$sysdir\calc.exe"
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ModifyFinishPage
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_LANGUAGE "English"

Section "Create shortcuts" SID_LNK
CreateShortcut ...
SectionEnd

Function ModifyFinishPage
${IfNot} ${SectionIsSelected} ${SID_LNK}
    
SendMessage $mui.FinishPage.Run ${BM_SETCHECK} ${BST_UNCHECKED0
    ShowWindow $mui
.FinishPage.Run 0
${EndIF}
FunctionEnd 

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump