I have a program that installs with non-visible UI. I am always debugging it because it runs from a USB device, and on different OSes.
I would like to be able to add a string or hotkey combo that would allow me to set a flag. This flag causes a message boxes to pop up at each different section.
I have everything set up except for the ability to silently capture this keyboard input. Anyone have any ideas? Let us say that I want to put it in while the splash screen is up, or during the first 5 seconds of the program, etc.
Secret Keyboard Input
10 posts
You can have it passed on as a command line switch. Use GetOptions to retrieve it from the command line.
Having some trouble with it.
After the Function .onInit but before Section "Main" I placed the example code:
After the Function .onInit but before Section "Main" I placed the example code:
Section "Test"and at the end of the file I placed the code for the function GetOptions
${GetOptions} "/S /T" "/T" $R0
IfErrors 0 +2
MessageBox MB_OK "Not found" IDOK +2
MessageBox MB_OK "Found"
SectionEnd
Function GetOptionsI did this just to test the workings of it. Well it doesn't work. Compile error:
!define GetOptions `!insertmacro GetOptionsCall`
!macro GetOptionsCall _PARAMETERS _OPTION _RESULT
Push `${_PARAMETERS}`
Push `${_OPTION}`
Call GetOptions
Pop ${_RESULT}
!macroend
Exch $1
Exch
Exch $0
Exch
...
...
Pop $2
Pop $1
Exch $0
FunctionEnd
Section: "Test"
Invalid command: ${GetOptions}
That's not the correct usage. The top of that documentation section shows the correct usage. You must first include TextFunc.nsh, then !insertmacro GetOptions and only then you can use the function. There's no need to copy the function code to your script.
I think you mean !include "FileFunc.nsh"
Okay, I've got it running, but it is still confusing.
I just want it to check if i added "/debug" to the end.
Okay, I've got it running, but it is still confusing.
I just want it to check if i added "/debug" to the end.
I'm using:
$R0 = null value, instead of "debug"
${GetOptions} "/debug" "/" $R0yet
MessageBox MB_OK "r0= $R0"
$R0 = null value, instead of "debug"
How is it not working? Does it simply ignore /debug? Is it the same code as above? If so, replace "/S /T" with $CMDLINE.
Section "Test"at the command line i enter "program.exe /debug" and the popup box returns "r0="
ClearErrors
${GetOptions} $CMDLINE "/" $R0
MessageBox MB_OK "r0= $R0"
SectionEnd
Okay, I've changed the code to just use GetParameters instead, since there will only be one switch.
Section "Test"
ClearErrors
${GetParameters} $DEBUG
MessageBox MB_OK "debug= $DEBUG"
SectionEnd
${GetParameters} $1
DetailPrint $1
${GetOptions} $1 "/debug=" $0
DetailPrint $0installer.exe /debug=yes