Search code examples
c#global-hotkey

Modifier Key Codes for Global Hotkey Registration


I am hooking a USB remote up to my software, and need to register global hotkeys to work with it. I have the code in place, and it is working as expected, but when I hook the remote up, I found that it requires a specific Left or Right Alt when dealing with the modifier keys.

In other words, right now I have the global hotkey set up to accept ALT + SHIFT + 0 to run a specific function. When I hooked the remote up, I realized that their mapping requires the specific Key modifier to be identified. Thus, I need to search specifically for L-ALT + L-SHIFT + 0. I have searched for these modifier mappings, but have not been able to find anything that says what they are. I have only been able to find the modifiers for the general ALT key rather than the specific L-ALT modifier.

Currently, I have my keys defined as such:

    public const int NOMOD = 0x0000;            //  No HotKey
    public const int ALT = 0x0001;              //  ALT
    public const int CTRL = 0x0002;             //  CTRL
    public const int SHIFT = 0x0004;            //  SHIFT
    public const int WIN = 0x0008;              //  WIN button
    public const int WM_HOTKEY_MSG_ID = 0x0312; //  Windows message ID for HotKey

I have tried to find a mapping for what the code would be for L-Alt, L-CTRL, and L-Shift, but have been unsuccessful. They don't seem to be ASCII. Does anyone know the correct codes for these, or where I can find them? Thanks.


Solution

  • I typed Keys and hit F12 to go to the definition and it has left alt and right alt listed as LMenu and RMenu with the values of 164 and 165. Does this help you or am I totally looking in the wrong place.