- NSIS Discussion
- Secret Keyboard Input
Archive: Secret Keyboard Input
torpark
2nd September 2006 05:59 UTC
Secret Keyboard Input
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.
kichik
2nd September 2006 12:40 UTC
You can have it passed on as a command line switch. Use GetOptions to retrieve it from the command line.
torpark
2nd September 2006 18:20 UTC
Having some trouble with it.
After the Function .onInit but before Section "Main" I placed the example code:
Section "Test"
${GetOptions} "/S /T" "/T" $R0
IfErrors 0 +2
MessageBox MB_OK "Not found" IDOK +2
MessageBox MB_OK "Found"
SectionEnd
and at the end of the file I placed the code for the function GetOptions
Function GetOptions
!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
I did this just to test the workings of it. Well it doesn't work. Compile error:
Section: "Test"
Invalid command: ${GetOptions}
kichik
2nd September 2006 18:32 UTC
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.
torpark
2nd September 2006 19:55 UTC
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.
torpark
2nd September 2006 19:57 UTC
I'm using:
${GetOptions} "/debug" "/" $R0
MessageBox MB_OK "r0= $R0"
yet
$R0 = null value, instead of "debug"
kichik
2nd September 2006 20:04 UTC
How is it not working? Does it simply ignore /debug? Is it the same code as above? If so, replace "/S /T" with $CMDLINE.
torpark
2nd September 2006 20:08 UTC
Section "Test"
ClearErrors
${GetOptions} $CMDLINE "/" $R0
MessageBox MB_OK "r0= $R0"
SectionEnd
at the command line i enter "program.exe /debug" and the popup box returns "r0="
torpark
2nd September 2006 20:12 UTC
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
kichik
2nd September 2006 20:14 UTC
${GetParameters} $1
DetailPrint $1
${GetOptions} $1 "/debug=" $0
DetailPrint $0
installer.exe /debug=yes