Archive: CreateShortcut - Hotkeys setting problem when using variables


CreateShortcut - Hotkeys setting problem when using variables
I am having problem setting hotkeys using CreateShortcut when using a variable for key combination.

The following code is not working (when hot key is set using a variable) this is raising a warning and when run it creates an hot key "NUM 7" instead of Alt+Ctrl+A

var HotKey (declared globally)

strcpy $HotKey "ALT|CONTROL|A"
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk" "$INSTDIR\Product.exe" "" "" "" "" "$HotKey"


Where as this code is working fine
CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\${PRODUCT_NAME}.lnk" "$INSTDIR\Product.exe" "" "" "" "" "ALT|CONTROL|A"

Thanks


Looks like that's just one of those things that you have to set at compile time (much like the icon resource).

If this is not something that is changeable by the user in your installer, and you're merely using $HotKey to make it easier for coworkers/others to check the code, use '!define Hotkey "ALT|CONTROL|A"' and '${HotKey}' instead.

If it -is- something you want the user to be able to change on installation, then you may just have to get crazy with a whole string of Select/Case statements.. a la...


${Select} $HotKey
${Case} A
CreateShortCut ... "ALT|CONTROL|A"
${Case} B
CreateShortCut ... "ALT|CONTROL|B"
...
${EndSelect}


Ouch, man.

you could modify the hotkey after the shortcut has been created by calling the IShellLink COM interface with the system plugin


seems to be a plugin fit for the task as well..
http://nsis.sourceforge.net/ShellLin...rtcut_Hot_Keys


Thanks for all reply ,

As suggested, I could do this using ShellLink plug-in, after creating a shortcut using CreateShortCut, I called ShellLink::SetShortCutHotkey to set the required hotkey