Problem using ${RunningX64} in NSIS - nsis

I am using the code below in several parts of my script.
${If} ${RunningX64}
; 64bit bits go here
${Else}
; 32bit bits go here
${EndIf}
In one function it runs perfectly fine, but the other calls will not work unless they are used after the initial call that executed correctly.
I have not been able to find any logical reason for this behavior. I have included both the LogicLib.nsh and x64.nsh heather files, but it goes through the 64 bit section.
What could it be? There does not seem to be any macros to initialize prior their use. Any ideas?

I'm using GetVersion plugin this way:
Var WINDOWS_ARCHITECTURE
GetVersion::WindowsPlatformArchitecture
Pop $WINDOWS_ARCHITECTURE ; 32 or 64

Related

NSIS: How to remove/hide MUI_LICENSEPAGE_TEXT_BOTTOM?

Hello to you who is reading this post. About a week ago I discovered NSIS and have just about managed to finish my first installer script. I managed to find answers to pretty much all of my questions through web searches, and have managed to create a pretty elaborate installer. There is one issue I can't figure out, as everything I have tried does not work and I can't find a solution online that I understand or is specific enough to be applied to this issue.
I'm using the modern UI "MUI2". I found some code to increase the size of the rich textbox on the license page which works great, but now the text at the bottom of the window (MUI_LICENSEPAGE_TEXT_BOTTOM) overlaps it and causes some visual bugs. Setting it to an empty string does not work and setting it to a single space does not work. I managed to get it to disappear with "FindWindow" and "GetDlgItem", but I'm not exactly a programmer so I don't have the intelligence or knowledge on how to set these up correctly. What I did manage to pull off, it also removed the rich textbox, and after several hours of defeat I finally gave up and turned to the internet.
It's kind of mind blowing to me that NSIS does not provide a simple way to remove controls. I don't want the "text bottom" label there at all, I want it gone or at the very least hidden. I know the handle I'm trying to remove is "1006" because I opened up the installer in Resource Hacker and removed the label from there. What bugs the me most is that actually worked perfectly and removes the label, but it also corrupts the installer and I have to use NCRC on command line to launch it. So scratch that as a workable solution...
TL;DR my question is: how do I hide or get rid of MUI_LICENSEPAGE_TEXT_BOTTOM?
MUI2 already has a variable you can use:
!include MUI2.nsh
!define MUI_PAGE_CUSTOMFUNCTION_SHOW HideMui2Text
!insertmacro MUI_PAGE_LICENSE
!insertmacro MUI_LANGUAGE "English"
Function HideMui2Text
ShowWindow $mui.LicensePage.Text 0
FunctionEnd
If you wanted to do it manually it would be
FindWindow $0 "#32770" "" $HWNDPARENT ; Find inner page
GetDlgItem $1 $0 1006 ; Find control
ShowWindow $1 0
When using Resource Hacker you need to copy the base file from NSIS\Contrib\UIs and in your script define MUI_UI to the path of your modified UI file.

Simulate Standard Windows Popup message Beep sound

I would like to simulate the standard windows popup message Beep sound in order to have each popup message in my script with the same sound effect.
In my script I use the default clause MUI_ABORTWARNING so, when the relative popup message is displayed, the standard windows popup message Beep is played.
For my purpose, I tryed to use the following API call but the sound effect is very different
System::Call "kernel32::Beep(i, i) b (${BEEP_FREQ_HZ}, ${BEEP_DURATION_MSEC})"
How can I do to accomplish the task?
Many thanks in advance to everyone that can help me on this.
Regards,
kernel32::Beep tries to use the little hardware speaker in your machine, if not available it uses the default system sound.
Use MessageBeep to generate a standard sound:
!define /IfNDef MB_ICONWARNING 0x00000030 ; You might want MB_ICONINFORMATION or MB_ICONSTOP instead
System::Call 'USER32::MessageBeep(i ${MB_ICONWARNING})'
If you are actually calling MessageBox in your NSIS code then you don't need to call MessageBeep, MessageBeep will be called for you if you use one of the MB_ICON* flags.

NSIS: Making Embedded ListView with CheckBoxes transparent

I have created a ListView with checkboxes using the embeddedLists.dll plugin. I need to make the background of the HeadingText transparent for this project.
I used WinSpy++ to get the handle_Id and tried this snippet, but it did not work.
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1211
SetCtlColors $0 "FFFFFF" "transparent"
Any pointers/help is very much appreciated.
Adding screenshot for clarity.
screenshot
Is your installer based on UMUI skin? Some 3rd party plug-ins may have issues with transparency and so on.
Anyway I noticed you use NSIS 2.46 which is pretty old, try to run the example in new NSIS 3 and new UMUI which has many fixes and improvements.
Little self promo: I have developed plug-in for NSIS similar to UMUI called Graphical Installer:
Feel free to try it: Graphical Installer website (Trial)

NSIS MessageBox jump offset

I'm not able to understand what's wrong with the below code for jumping to particular offset if MessageBox returns IDNO.
Below code is to quit installer while IDNO is selected, but it always jumping to Goto endCurrentBlock line
MessageBox MB_YESNO|MB_ICONEXCLAMATION "Would you like to continue installation?" IDNO +3
!insertmacro ShowStatus "Failed to install software"
Goto endCurrentBlock
Quit
If I use a absoule label for jump it's working good. What could be the reason?
Jumping by offset skips x number of NSIS instructions but !insertmacro is a preprocessor instruction that might expand to zero, one or several NSIS instructions.
It is not recommended to combine offset jumps and !insertmacro because it can break your code just by changing the macro...

NSIS -- Customize existing button?

Thanks for reading this.
I am making a program and I choose to package it using NSIS after getting disappointed by Inno.
I am trying to make a 2 steps install wizard. I could accomplish this by using Nsdialogs and a custom page.
Please see this image: here
Is it possible to change the "Install" button to became "I Agree" as in the license page?
and if this is possible, can this button be colored?
I have searched about this and I found some talk about a plugin called 'Buttonevent'. I download it and I saw the examples. AS I understood this can be used only to Add new buttons Not to change existing ones.
please help me if there is any clues.
That's a lot of code for a one-line solution. LicenseText is the attribute you are looking for. You should also consider using the license page as it is intended, too.
Page License
!include nsDialogs.nsh
Page Custom MyPageCreate
Page InstFiles
Function MyPageCreate
nsDialogs::Create 1018
Pop $0
GetDlgItem $1 $hwndparent 1 ; Get handle to Install/Next button
${NSD_SetText} $1 "$(^AgreeBtn)"
nsDialogs::Show
FunctionEnd
Changing button colors is a lot of work and cannot be done in NSIS without a plugin...

Resources