You are here

nsis gui help

4 posts / 0 new
Last post
Travis Carrico
Offline
Last seen: 16 years 7 months ago
Developer
Joined: 2006-10-22 00:30
nsis gui help

ok here's the thing. i want to make a gui using the nsdialogs plugin (which is what digitxp used for his gamesuit portable) with a listbox, buttons, etc. This is done completely in functions without using section main. my question is how do i use the two together. if i write the gui menu, how can i integrate it into the normal PA nsis launcher? i was playing around with it trying before but had no luck. sorry, i'm okay at scripting but i'm still a programming noob

wraithdu
Offline
Last seen: 12 years 1 month ago
Developer
Joined: 2007-06-27 20:22
Depends what exactly you

Depends what exactly you want to do. Interaction with buttons/controls in the GUI calls other functions to perform tasks.

Why don't you describe what you want to accomplish in detail, and post what code you have so people can take a look at what you're doing.

Travis Carrico
Offline
Last seen: 16 years 7 months ago
Developer
Joined: 2006-10-22 00:30
Well i don't really have my

Well i don't really have my code done or anything but here's an example modified from digitxp's gamesuitportable

!define MUI_CUSTOMFUNCTION_GUIINIT myGuiInit
Page custom nsDialogsPage nsDialogsPageLeave ; 
and the main nsis isn't done either but something like this with some functions and variables

;Copyright (C) 2004-2008 John T. Haller of PortableApps.com
;Copyright (C) 2008 Travis Carrico

;This software is OSI Certified Open Source Software.
;OSI Certified is a certification mark of the Open Source Initiative.

;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;as published by the Free Software Foundation; either version 2
;of the License, or (at your option) any later version.

;This program is distributed in the hope that it will be useful,
;but WITHOUT ANY WARRANTY; without even the implied warranty of
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;GNU General Public License for more details.

;You should have received a copy of the GNU General Public License
;along with this program; if not, write to the Free Software
;Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

!define PORTABLEAPPNAME "JkDefrag Portable"
!define APPNAME "JkDefrag"
!define NAME "JkDefragPortable"
!define VER "1.5.5.0"
!define WEBSITE "N/A"
!define DEFAULTAPPDIR "JkDefrag"

;=== Program Details
Name "${PORTABLEAPPNAME}"
OutFile "..\..\${NAME}.exe"
Caption "${PORTABLEAPPNAME} | PortableApps.com"
VIProductVersion "${VER}"
VIAddVersionKey ProductName "${PORTABLEAPPNAME}"
VIAddVersionKey Comments "Allows ${APPNAME} to be run from a removable drive.  For additional details, visit ${WEBSITE}"
VIAddVersionKey CompanyName "PortableApps.com"
VIAddVersionKey LegalCopyright "John T. Haller"
VIAddVersionKey FileDescription "${PORTABLEAPPNAME}"
VIAddVersionKey FileVersion "${VER}"
VIAddVersionKey ProductVersion "${VER}"
VIAddVersionKey InternalName "${PORTABLEAPPNAME}"
VIAddVersionKey LegalTrademarks "PortableApps.com is a Trademark of Rare Ideas, LLC."
VIAddVersionKey OriginalFilename "${NAME}.exe"

;=== Runtime Switches
CRCCheck On
WindowIcon Off
SilentInstall Silent
AutoCloseWindow True
RequestExecutionLevel user

; Best Compression
SetCompress Auto
SetCompressor /SOLID lzma
SetCompressorDictSize 32
SetDatablockOptimize On

;=== Include
!include "FileFunc.nsh"
!insertmacro GetParameters
!insertmacro GetRoot
!insertmacro GetDrives
!include "MUI.nsh"

;=== Program Icon
Icon "..\..\App\AppInfo\appicon.ico"

;=== Icon & Stye ===
!define MUI_ICON "..\..\App\AppInfo\appicon.ico"

;=== Languages
!insertmacro MUI_LANGUAGE "English"

LangString LauncherFileNotFound ${LANG_ENGLISH} "${PORTABLEAPPNAME} cannot be started. You may wish to re-install to fix this issue. (ERROR: $MISSINGFILEORPATH could not be found)"
LangString LauncherAlreadyRunning ${LANG_ENGLISH} "Another instance of ${APPNAME} is already running. Please close other instances of ${APPNAME} before launching ${PORTABLEAPPNAME}."
LangString LauncherAskCopyLocal ${LANG_ENGLISH} "${PORTABLEAPPNAME} appears to be running from a location that is read-only. Would you like to temporarily copy it to the local hard drive and run it from there?$\n$\nPrivacy Note: If you say Yes, your personal data within ${PORTABLEAPPNAME} will be temporarily copied to a local drive. Although this copy of your data will be deleted when you close ${PORTABLEAPPNAME}, it may be possible for someone else to access your data later."
LangString LauncherNoReadOnly ${LANG_ENGLISH} "${PORTABLEAPPNAME} can not run directly from a read-only location and will now close."

Var PROGRAMDIRECTORY
Var SETTINGSDIRECTORY
Var ADDITIONALPARAMETERS
Var EXECSTRING
Var PROGRAMEXECUTABLE
Var INIPATH
Var SECONDARYLAUNCH
Var DISABLESPLASHSCREEN
Var MISSINGFILEORPATH
Var PDRIVE
Var DEFAULTEXE
Var PLETTER
Var FLASH

Function Flash
	StrCmp $9 $R0 0 +3
	StrCpy $R1 $8
	StrCpy $0 StopGetDrives

	Push $0
FunctionEnd
	
Section "Main"
	;=== Check architecture
	GetVersion::WindowsPlatformArchitecture
		Pop $R0
		StrCmp $R0 "32" x32
		StrCmp $R0 "64" x64
	
	x32:
		StrCpy "$DEFAULTEXE" "JkDefrag.exe"
		Goto DriveLetter
	
	x64:
		StrCpy "$DEFAULTEXE" "JkDefrag64.exe"
		Goto DriveLetter
	
	DriveLetter:
		${GetRoot} "$EXEDIR" $R0
		StrCpy "$PLETTER" "$R0"
		
		StrCpy $R0 "$PLETTER\"
		StrCpy $R1 "invalid"

		${GetDrives} "ALL" "Flash"
		StrCmp $R1 "FDD" FlashDrive
		Goto Option
	
	FlashDrive:
		StrCpy "$FLASH" "true"
		Goto Option
	
********Normal PA code****

	LaunchNow:
		SetOutPath "$PROGRAMDIRECTORY"
		Exec "$EXECSTRING $PDRIVE"
		
	CheckRunning:
		Sleep 1000
		FindProcDLL::FindProc "$DEFAULTEXE"                  
		StrCmp $R0 "1" CheckRunning

	Delete "$PROGRAMDIRECTORY\JkDefrag.log"
	Sleep 500
	Goto TheEnd
	
	LaunchAndExit:
		SetOutPath "$PROGRAMDIRECTORY"
		Exec "$EXECSTRING $PDRIVE"

	TheEnd:
		newadvsplash::stop /WAIT
SectionEnd

i'm sorry i don't really know what i'm doing with this. i just wanted to create a gui for jkdefrag in nsis. anyways how would i integrate two scrips such as these?

wraithdu
Offline
Last seen: 12 years 1 month ago
Developer
Joined: 2007-06-27 20:22
Not really suited to NSIS

This is why NSIS isn't really used to create GUIs, although it can do it. NSIS is really an installer. The launchers we create are basically invisible one-page installers.

When using the GUI, everything in NSIS is based on "pages". The welcome screen is a page, the dialog where you choose an install directory is a page, the License agreement is a page.

To do what you want, you have to creat the GUI as the first "page". Then when you've chosen your GUI options (as a user) you would click Run (or install, or whatever you call it). This would throw you into either another page, or as Simeon/digitxp/me have done, just goes to the page leave function. Your "Section" is only executed if you have "Page instfiles".

Once you've got your head around the architecture, what you want is nearly the same as the GamePack launcher. Your GUI would go in the main nsDialogs page, and your launcher code would go in the leave function.

Of course all your defines and variables and such would go in the normal places at the beginning of the script.

Log in or register to post comments