Archive: Secret Keyboard Hotkey


Secret Keyboard Hotkey
  Hi all,
I would like to be able to hit a secret hotkey combo (e.g. CTRL+ALT+P) that would allow me to call a function which causes a message box to pop up. Though I don't want to retrieve it from the command line (see Secret Keyboard Input).

Rather setting the hotkey with WM_SETHOTKEY in the SendMessage command. When the user presses the hot key, I'd like to catch a WM_SYSCOMMAND message with wParam equal to SC_HOTKEY and lParam equal to the window's handle. Maybe anyone knows any solution.

Regards,
Rainer


I tried this to set up the hotkey (1616 is the decimal key code of CTRL+ALT+P:


SendMessage $HWNDPARENT ${WM_SETHOTKEY} 1616 0 

>
The return value of WM_GETHOTKEY is the virtual-key code and modifiers for the hot key...


SendMessage $HWNDPARENT ${WM_GETHOTKEY} 0 0 $hotkey

Pop $result
MessageBox MB_OK
|MB_ICONINFORMATION $hotkey
>
After pressing CTRL+ALT+P the dialog window pops up but I don't know how to call a function after pressing the hotkey or at least open a further window.

[SOLVED] Secret Keyboard Hotkey
  To call a function from my script, I patched the nsDialogs plugin to catch WM_SYSCOMMAND message with wParam SC_HOTKEY. The callback routine is similar to nsDialogs:OnBack.


A small compiled version is available here:

http://stashbox.org/617998/nsDialogs.zip



SendMessage $HWNDPARENT ${WM_SETHOTKEY} 1616 0 

>
- Sets the hotkey for CTRL+ALT+P


nsDialogs::OnHotkey function_address 

>
- Sets the callback function which will be called after pressing the hotkey

The more elegant way of setting the callback is simply to insert following macro to nsDialogs.nsh.

insertmacro __NSD_DefineDialogCallback Hotkey 

>
Usage:

function_address 

>