Notice/Message before a page..
How can i put a message up just before the directory page apears... cos i want to tell them something before it apears or when it apears...
Archive: Notice/Message before a page..
Notice/Message before a page..
How can i put a message up just before the directory page apears... cos i want to tell them something before it apears or when it apears...
Use the page show_function or pre_function!
More info at "4.5.4 Page" in the documentation ;)
I added:
Function .onVerifyInstDir
MessageBox MB_OK "My message"
FunctionEnd
But it shows at end of component page and start of directory page...
Maybe this will help.
MUI_PAGE_CUSTOMFUNCTION_PRE MyMessage
MUI_PAGE_DIRECTORY
Function MyMessage
MessageBox MB_OK "My message"
FunctionEnd
~Berks
Ermm, Im using ExperienceUI
SO MUI_PAGE_DIRECTORY...etc dont work
I see.. Sorry.
How about this one..
!define XPUI_PAGE_CUSTOMFUNCTION_PRE MyMessage
!insertmacro XPUI_PAGE_DIRECTORY
Function MyMessage
MessageBox MB_OK "My message"
FunctionEnd
~Berks
Originally posted by XxXGoDThe .onVerifyInstDir function will be called every time the user changes the directory on the directory page. It will be called even when the user changes only one single character of the directory. And it will be called when a new folder is highlighted in the "Browse..." dialog. Therefore this function is not suitable for displaying message boxes. Make a custom "pre_function" as described in chapter "4.5.4 Page" of the NSIS manual. Reading the manual can help a lot...
I added:
Function .onVerifyInstDir
MessageBox MB_OK "My message"
FunctionEnd
But it shows at end of component page and start of directory page...
; pages
page directory MyPreDirectoryFunction
[..]
Function MyPreDirectoryFunction
MessageBox MB_OK "Be warned, you'll have to choose a directory now!"
FunctionEnd
LoRd_MuldeR
That doesn't work for me.
yelkrebb that pops up one and works for me but i cant seem to make it pop up at the directory page, it pops up at the start just after my spash screen
My code is correct, though ExperienceUI does hide the actual "page" commands in it's macros! So you will have to use the Syntax provided by ExperienceUI instead of the "native" NSIS syntax in that case. Should be documented in the ExperienceUI manual...
This is how I think it should work:
; page macros
!define XPUI_PAGE_CUSTOMFUNCTION_PRE MyMessage
!insertmacro XPUI_PAGE_DIRECTORY
; custom functions
Function MyMessage
MessageBox MB_OK "My message"
FunctionEnd
!insertmacro: XPUI_PAGE_DIRECTORY
!insertmacro: XPUI_PAGECHECKS
Call must be used with function names starting with "un." in the uninstall section.
Usage: Call function_name | [:label_name]
Error in macro XPUI_PAGE_CUSTOMFUNCTION on macroline 3
Error in macro XPUI_PAGE_DIRECTORY on macroline 38
Error in script "C:\Documents and Settings\Ryan\Desktop\h1o.nsi" on line 110 -- aborting creation process
Are doing this for the UNinstaller ???
Please post your complete script code...
[EDIT]
This is from XPUI docs, took my one click in Google to find ;)
Using custom page/GUI functions[EDIT²]
XPUI_CUSTOMFUNCTION_GUIINIT myFunction - Define this to call custom function "myFunction" during the installer's GUI initialization.
XPUI_CUSTOMFUNCTION_GUIEND myFunction - Define this to call custom function "myFunction" during the installer's GUI de-initialization. Use this to unload any plugins you have and delete any temporary files that you dumped on to the user's hard drive.
XPUI_PAGE_CUSTOMFUNCTION_PRE myFunction - Call function "myFunction" during the early initialization of an installer page.
XPUI_PAGE_CUSTOMFUNCTION_SHOW myFunction - Call function "myFunction" right before an installer page shows.
XPUI_PAGE_CUSTOMFUNCTION_LEAVE myFunction - Call function "myFunction" while an installer page is unloading.
NOTE: After defining the XPUI_PAGE_CUSTOMFUNCTION symbols, insert the page of your choice, and that will be the page that calls your custom functions. You will need to define the CUSTOMFUNCTION symbols for every page that you want a custom function for.
I fixed it
Had to do:
${Page} Welcome
; ${LicensePage} "E:\Documents and Settings\User\Desktop\lic.rtf"
${Page} Components
!define XPUI_PAGE_CUSTOMFUNCTION_PRE AccountDir
${Page} Directory
${Page} InstFiles
${Page} Finish
As I said: You must put the XPUI_PAGE_CUSTOMFUNCTION_PRE define right before the page macro. Don't put anything in between, especially no other page macro!
Append lines to a text file this way:
; open file
ClearErrors
FileOpen $0 "autoexec.cfg" a
IfErrors FileErrors
; seek to the end of the file
FileSeek $0 0 END
; append a few lines
FileWrite $0 "Rabbit$\r$\n"
FileWrite $0 "Umbrella$\r$\n"
FileWrite $0 "Joker$\r$\n"
; close file
FileClose $0
FileErrors:
What does the foloowing do:
$\r$\n
$\r$\n are symbols for a carriage return ($\r) and new line ($\n) character.
Works perfectly, however on some peoples pc's it wont be there..
How can i add it so IF that file isn't there it will put it there, but if it is it wont... but the other files what im putting in i want to overright
You can check for file existence with IfFileExists command ;)
Also, the above code should work, no matter if the file exists before or not...
Originally posted by LoRd_MuldeRBut theres 1 file what i dont want it to overwrite.
You can check for file existence with IfFileExists command ;)
Also, the above code should work, no matter if the file exists before or not...
IfFileExists $INSTDIR\autoexec.cfg autoexecfound
File "C:\Documents and Settings\Ryan\Desktop\autoexec.cfg"
autoexecfound:
ClearErrors
FileOpen $0 "$INSTDIR\autoexec.cfg" a
IfErrors FileErrors
FileSeek $0 0 END
FileWrite $0 "TestLine$\r$\n"
FileClose $0
FileErrors:
You code should extract a the "autoexec.cfg" to the $INSTDIR folder, but *only* when there is no such file yet. If the file already exists, that part will be skipped. In both cases one line, namely "TestLine", will be appended to the "autoexec.cfg" file. One tip though: You can not be sure that the last line of the user's "autoexec.cfg" file has a carriage return at it's end. So it might be more safe to do it this way:
IfFileExists $INSTDIR\autoexec.cfg autoexecfound
File "C:\Documents and Settings\Ryan\Desktop\autoexec.cfg"
autoexecfound:
ClearErrors
FileOpen $0 "$INSTDIR\autoexec.cfg" a
IfErrors FileErrors
FileSeek $0 0 END
FileWrite $0 "$\r$\n" ; <-- THIS IS NEW
FileWrite $0 "TestLine$\r$\n"
FileClose $0
FileErrors:
Or even better:
IfFileExists $INSTDIR\autoexec.cfg autoexecfound
File "C:\Documents and Settings\Ryan\Desktop\autoexec.cfg"
autoexecfound:
ClearErrors
FileOpen $0 "$INSTDIR\autoexec.cfg" a
IfErrors FileErrors
FileSeek $0 1 END
FileReadByte $0 $1
StrCmp $1 10 CarriageReturnFound:
FileWrite $0 "$\r$\n"
CarriageReturnFound:
FileWrite $0 "TestLine$\r$\n"
FileClose $0
FileErrors:
yeah, awesome i learnt alot today :D