I am using the below code to register hotkeys using c#. But sometimes i get the exception throwing "Couldn’t register the hot key." What will be the reason for this error ? And for not being consistent. How can i handle this ?
public void RegisterHotKey(ModifierKeys modifier, Keys key)
{
// increment the counter.
_currentId = _currentId + 1;
// register the hot key.
if (!RegisterHotKey(_window.Handle, _currentId, (uint)modifier, (uint)key))
throw new InvalidOperationException("Couldn’t register the hot key.");
}
Reading the MSDN description for RegisterHotKey I came across:
RegisterHotKey fails if the keystrokes specified for the hot key have already been registered by another hot key.
Ref
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With