Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error : Could not register Hot Key using c#

Tags:

c#

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.");
    }
like image 858
Anuya Avatar asked Aug 12 '10 07:08

Anuya


1 Answers

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

like image 58
Ralf de Kleine Avatar answered Sep 21 '22 15:09

Ralf de Kleine