Archive: Secret Keyboard Input


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.


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:

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}

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.


I'm using:

${GetOptions} "/debug" "/" $R0
MessageBox MB_OK "r0= $R0"
yet

$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"
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="

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 $0
installer.exe /debug=yes