.:: CODE SNIPPET ::.

"Your time is limited, so don't waste it living someone else's life"

Tag Archives: install

Simply control selected components in NSIS component page


This is really a simple way to control the constraint between component in the NSIS component page

Function .onSelChange
	Pop $0
	${Switch} $0
		${Case} 0
			SectionSetFlags ${SEC_GUI} 0
			SectionSetFlags ${SEC_CONS} 1
			${Break}
		${Case} 1
			SectionSetFlags ${SEC_DS} 0
			SectionSetFlags ${SEC_SIM_MACH4} 0
			SectionSetFlags ${SEC_SIM_PM1} 0
			SectionSetFlags ${SEC_SIM_PM2} 0
			SectionSetFlags ${SEC_SIM_PM3} 0
          
			SectionSetFlags ${SEC_MACH4} 0
			SectionSetFlags ${SEC_PM1} 0
			SectionSetFlags ${SEC_PM2} 0
			SectionSetFlags ${SEC_PM3} 0
			SectionSetFlags ${SEC_CONS} 0
			${Break}
		${Case} 2
			SectionSetFlags ${SEC_DS} 1
			SectionSetFlags ${SEC_GUI} 0
			
			SectionSetFlags ${SEC_MACH4} 0
			SectionSetFlags ${SEC_PM1} 0
			SectionSetFlags ${SEC_PM2} 0
			SectionSetFlags ${SEC_PM3} 0
			${Break}
		${Case} 3
			SectionSetFlags ${SEC_DS} 1
			SectionSetFlags ${SEC_GUI} 0
			
			SectionSetFlags ${SEC_MACH4} 0
			SectionSetFlags ${SEC_PM1} 0
			SectionSetFlags ${SEC_PM2} 0
			SectionSetFlags ${SEC_PM3} 0
			${Break}
		${Case} 4
			SectionSetFlags ${SEC_DS} 1
			SectionSetFlags ${SEC_GUI} 0
			
			SectionSetFlags ${SEC_MACH4} 0
			SectionSetFlags ${SEC_PM1} 0
			SectionSetFlags ${SEC_PM2} 0
			SectionSetFlags ${SEC_PM3} 0
			${Break}
		${Case} 5
		${Case} 6
		${Case} 7
		${Case} 8
			SectionSetFlags ${SEC_DS} 1
			SectionSetFlags ${SEC_GUI} 0
			SectionSetFlags ${SEC_CONS} 0
			${Break}
		${Case} 9
		${Case} 10
		${Case} 11
		${Case} 12
		${Case} 13
		${Case} 14
			SectionSetFlags ${SEC_DS} 1
			SectionSetFlags ${SEC_GUI} 0
			${Break}
	${EndSwitch}
FunctionEnd
Advertisements

How to execute batch file and read the out stream in NSIS


Plugin ExecDos will help us to do the title’s content easier.
First, we normally create an nsis wizard page like this

Plugin ExecDos will help us to do the title's content easier.
First, we normally create an nsis wizard page like this
Var hCtl_test
Var hCtl_test_ProgressBar1
Var hCtl_test_TextBox1
Var hCtl_test_Button1

Function fnc_test_Create
  
	; === test (type: Dialog) ===
	nsDialogs::Create 1018
	Pop $hCtl_test
	${If} $hCtl_test == error
		Abort
	${EndIf}
	!insertmacro MUI_HEADER_TEXT "Dialog title..." "Dialog subtitle..."
  
	; === ProgressBar1 (type: ProgressBar) ===
	${NSD_CreateProgressBar} 8u 7u 280u 13u ""
	Pop $hCtl_test_ProgressBar1
	SetCtlColors $hCtl_test_ProgressBar1 0x3399FF 0xF0F0F0
  
	; === TextBox1 (type: TextMultiline) ===
	nsDialogs::CreateControl EDIT ${DEFAULT_STYLES}|${ES_AUTOHSCROLL}|${ES_AUTOVSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN}|${WS_HSCROLL}|${WS_VSCROLL} ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE} 8u 23u 280u 84u ""
	Pop $hCtl_test_TextBox1
	SendMessage $hCtl_test_TextBox1 ${ES_MULTILINE} 0 0
  
	; === Button1 (type: Button) ===
	${NSD_CreateButton} 238u 111u 49u 13u "Button1"
	Pop $hCtl_test_Button1
	${NSD_OnClick} $hCtl_test_Button1 onButtonClick
  
FunctionEnd

; dialog show function
Function fnc_test_Show
	Call fnc_test_Create
	nsDialogs::Show $hCtl_test
FunctionEnd
Function appendText
	Pop $0
	MessageBox MB_OK $0
FunctionEnd

Function onButtonClick
	GetFunctionAddress $R1 appendText
	ExecDos::exec /ASYNC /TOFUNC "batfile.bat" $R1
FunctionEnd
%d bloggers like this: