"Unable to add Hotkey()" Message - Forum

Forum Navigation
You need to log in to create posts and topics.

"Unable to add Hotkey()" Message

I am experimenting with a simple utility to launch both Notepad and Wordpad with a global hotkey and I'm getting the following almost continuously:

"Unable to add Hotkey()"

However, after clicking OK the hotkey appears to be functional in most cases...

I'm getting the message if I minimize the app (tray icon) and then restore it again, if I try to close the app by right clicking the tray icon. But sometimes also if another application is launched (which then takes the focus).

An Occasionally after trying to set a new hotkey, I'm getting "No such hot key". Then after setting a new one it seems to work again.

I take it I can add a second or third application to this utility? I added the variable for Wordpad but that does not seem to work.

I attached the app.

Uploaded files:
  • You need to login to have access to uploads.

@talker

I think you have unnecessary commands on the Activation tab (in the project properties). Try my simplified demo file, based on your project. Everything works fine.

Uploaded files:
  • You need to login to have access to uploads.

Thanks Vadim.

It works fine now during one session. But when the app is closed the hotkeys are not being stored.

In the initial version the following was in startup:

ShowErrors "False"
RegistryRead "HKEY_CURRENT_USER" "Software\[PubTitle]\Modifier" "[Modifier]"
If "[Modifier]" "=" ""
SetVar "[Modifier]" "Alt"
EndIf
RegistryRead "HKEY_CURRENT_USER" "Software\[PubTitle]\Letter" "[Letter]"
If "[Letter]" "=" ""
SetVar "[Letter]" "N"
EndIf
ShowErrors "False"

.assign the hot key (requires NeoBookKB plug-in)
SetVar "[HotKey]" "[Modifier]+[Letter]"
kbAddHotKey "[HotKey]" "notepad"
Endif
ShowErrors "False"
SetVar "[InitOK]" "True"

Apart from the obvious glitches this caused (and it would reset the hotkey to Alt+n upon initial launch) it did save the setting after that. For the notepad entry at least.

Any ideas how to make your version save as well?

 

@talker

Yes, of course you can store keyboard shortcuts in the registry, I do that too. As for the above code:
1) There is no sense in repeating the ShowErrors "False" command in one script several times because it is valid until it is cancelled by the ShowErrors "True" command.
2) There is an extra EndIf, but it's not essential.
I have written a little extra code to make the project save hotkeys to your two favorite applications. Keep in mind that you are creating global hotkeys. This means that if you make Ctrl+C to call Notepad, you will not be able to copy text with this combination (Notepad will appear every time). That is, for the functions of your application, it is better to choose other, less used keyboard shortcuts.

Uploaded files:
  • You need to login to have access to uploads.
luishp and proforma.guyot have reacted to this post.
luishpproforma.guyot

Thank you Vadim, it's working now :-)