Archive: Go to a NSIS page!


Go to a NSIS page!
  HI. :)

I read the documentation about how to jump a NSIS page, so i need to jump to a page specific if a user select one option u other option.

Well I set this in my script:

# Installer pages
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(MUILicense)
Page custom SetupType SetupTypeLeave
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

Function RelGotoPage
IntCmp $R9 0 0 Move Move
StrCmp $R9 "X" 0 Move
StrCpy $R9 "120"

Move:
SendMessage $HWNDPARENT "0x408" "$R9" ""
FunctionEnd
>
Them i put this:


${EndIf} 


But i confuse because the third page of NSIS is my custom page and then it shows me the install page. What is the order of the NSIS pages that shows with "StrCpy $R9 3" or for example 1,2,3,4, etc... ?

It's a relative jump. If you pass '3', it should jump three pages forward. So where you end up depends entirely on where you're jumping from.

Also, why on earth would you want to jump 120 pages? o__O


Going forward any number than there are pages simulates a Cancel click.

Stu


Originally posted by MSG
It's a relative jump. If you pass '3', it should jump three pages forward. So where you end up depends entirely on where you're jumping from.

Also, why on earth would you want to jump 120 pages? o__O
OK, thanks i change this for 8 pages in total... now i see how this work with relative jumps.

But there's also a problem, because the first condition work nice and goes to install files but if i select de second and try to jump to !insertmacro MUI_PAGE_DIRECTORY page then the installer generated an error and exits from installer.

May be it is a bug ? :stare:

no idea about the crash (might need full example code)... but if you only need to move forward, I'd recommend using the technique of calling Abort in the pages' Pre function. Use a variable to indicate which page you want to land on and call Abort in every page that is not the page you want.


hi.

I get the same problem... crash if i jump to directory page, maybe the reason is the value 1 of StrCpy $R9 1 because it's reserved value for next page ?.

I put my script, any help please!


# Página - Bienvenida

>!insertmacro MUI_PAGE_WELCOME

># Página - Licencia
>!insertmacro MUI_PAGE_LICENSE $(MUILicense)

># Página - Tipo de instalación
>Page custom TipoInstalacion TipoInstalacionLeave

># Página - Directorio
>!define MUI_PAGE_CUSTOMFUNCTION_PRE Directorio_PreFunction
!insertmacro MUI_PAGE_DIRECTORY

># Página - Menu Inicio
>!define MUI_PAGE_CUSTOMFUNCTION_PRE MenuInicio_PreFunction
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup

># Página - Acceso Directo
>Page custom AccesoDirecto

># Página - Instalación
>!define MUI_PAGE_CUSTOMFUNCTION_PRE Instalacion_PreFunction
!insertmacro MUI_PAGE_INSTFILES

># Página - Finalizar
>!define MUI_PAGE_CUSTOMFUNCTION_PRE Finalizar_PreFunction
!insertmacro MUI_PAGE_FINISH

># Define la función FunAbo
>!define MUI_CUSTOMFUNCTION_ABORT FunAbo

># Páginas de desinstalación
>!insertmacro MUI_UNPAGE_CONFIRM
>!insertmacro MUI_UNPAGE_INSTFILES

># Function jump pages
>Function RelGotoPage
IntCmp $R9 0 0 Move Move
StrCmp $R9"X" 0 Move
StrCpy $R9"6" ;Nº total de páginas

Move:
SendMessage $HWNDPARENT "0x408" "$R9" ""
>FunctionEnd


># Custom function SetupType
>Function TipoInstalacion
StrCpy $R8 1;esta es la primera página

>!insertmacro MUI_HEADER_TEXT "$(Tit1)" "$(SubTit1)"

>nsDialogs::Create /NOUNLOAD 1018
Pop $CD1

${If} $CD1 == error
Abort
${EndIf}

${
NSD_CreateRadioButton} 12u 20u 100% 20 "$(InstRap)"
Pop $Rad2

# Por defecto selecciona la Instalación rápida
${NSD_SetState} $Rad2 ${BST_CHECKED}

${NSD_CreateRadioButton} 12u 33u 100% 20 "$(InstPer)"
Pop $Rad1

${NSD_CreateLabel} 0u 0u 100% 20 "$(L1)"
Pop $Lab1

nsDialogs::Show
FunctionEnd

>Function TipoInstalacionLeave
># Guarda el estado del control del RadioButton
${NSD_GetState} $Rad1 $SelPer
${NSD_GetState} $Rad2 $SelRap

># Condición basada en la selección del RadioButton
${If} $SelRap == ${BST_CHECKED}
StrCpy $R9 4 ; va hacia la página de instalación
Call RelGotoPage
${Else}
StrCpy $R9 1 ; va hacia la página de seleccionar directorio
Call RelGotoPage
${EndIf}
>FunctionEnd


># Directory page
>Function Directorio_PreFunction
StrCpy $R8 2;esta es la segunda página
FunctionEnd

># Startmenu page
>Function MenuInicio_PreFunction
StrCpy $R8 3;esta es la tercera página
FunctionEnd


># Custom function Shorcut
>Function AccesoDirecto
StrCpy $R8 4;esta es la cuarta página

>!insertmacro MUI_HEADER_TEXT "$(Tit2)" "$(SubTit2)"

>nsDialogs::Create /NOUNLOAD 1018
Pop $CD2

${If} $CD2 == error
Abort
${EndIf}

${NSD_CreateCheckBox} 0u 14u 100% 20 "$(AccEsc)"
Pop $Check1

${NSD_CreateCheckBox} 0u 33u 100% 20 "$(AccIni)"
Pop $Check2

${NSD_CreateLabel} 0u 0u 100% 20 "$(L2)"
Pop $Lab2

nsDialogs::Show
FunctionEnd


># Installation page
>Function Instalacion_PreFunction
StrCpy $R8 5;esta es la quinta página
FunctionEnd

># Finish page
>Function Finalizar_PreFunction
StrCpy $R8 6;esta es la sexta página
FunctionEnd


># Custom function abort
>Function FunAbo
StrCmp $R8 1 0 End;Compare the variable with the
;page index of your choice
StrCpy $R9 1
Call RelGotoPage
Abort
End:
>FunctionEnd
>
PD... Sorry for some strings in spanish language i'm spanish :)

Originally posted by thanatos83
hi.

I get the same problem... crash if i jump to directory page, maybe the reason is the value 1 of StrCpy $R9 1 because it's reserved value for next page ?.

I put my script, any help please!
Thanks for the semi-full example; it gives us something to work with :)

Those who want to poke at it, the following is missing (just put it at the top):

"MUI2.nsh"

>var StartMenuGroup
>var CD1
>var CD2
>var Check1
>var Check2
>var Lab1
>var Lab2
>var Rad1
>var Rad2
>var SelPer
>var SelRap
Outfile "$%temp%\temp.exe"

>Section
SectionEnd
>
On to the issue at hand, then... the problem in your script appears to be that you're calling 'RelGotoPage 1' from your Custom Page's Leave function. You can't do that, as NSIS will get stuck in a loop. Not sure why, but it does :)

As you only need to go +1 page anyway, you can just -not- call "RelGotoPage" at all, and NSIS will take the user to the next page as usual :)

Exactly, i removed the part in the condition:

${Else}
StrCpy $R9 1 ; va hacia la página de seleccionar directorio
Call RelGotoPage
${EndIf}

So it seems NSIS was getting in a constant loop, and now work fine...

Thanks for help :)


No prob :) I'd still recommend using the other method, seeing as you're only going forward... as you can then easily re-order pages, add/remove pages, etc. without having to worry about updating the relGotoPage index numbers. But this should definitely work :)