Why I can Not Get the WM_HOTKEY msg

S

steel

Hi, everyone, I am fighting with a project with 5 Hotkey registerd. but
when the VK code is 66 67 68 69 71, the WM_HotKey msg can not fired,
but if changed the VK code to 117 ... 121 , the Project runs well. I
have look up the MSDN, but get no answerns yet.Can anyone make me known
the reason?

any suggestions and solutions will be very appreciated.
 
S

steel

I have found that when the Vitual KeyCode is 66-70, the system viewed
it as normal keyEvent, Not HotKey event. the related code:

public enum KeysHardware : int
{
Hardware1 = 66, //117,//
Hardware2 = 67, //118,//
Hardware3 = 68, //119,//
Hardware4 = 69, //120,//
Hardware5 = 71 // 121 //
}

public static void RegisterRecordKey(IntPtr hWnd)
{
bool Ret;
Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware1);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware1,
KeyModifiers.None, (int)KeysHardware.Hardware1);


Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware2);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware2,
KeyModifiers.None, (int)KeysHardware.Hardware2);

Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware3);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware3,
KeyModifiers.None, (int)KeysHardware.Hardware3);

Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware4);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware4,
KeyModifiers.None, (int)KeysHardware.Hardware4);
}
 
S

steel

I have found that when the Vitual KeyCode is 66-70, the system viewed
it as normal keyEvent, Not HotKey event. the related code:

public enum KeysHardware : int
{
Hardware1 = 66, //117,//
Hardware2 = 67, //118,//
Hardware3 = 68, //119,//
Hardware4 = 69, //120,//
Hardware5 = 71 // 121 //
}

public static void RegisterRecordKey(IntPtr hWnd)
{
bool Ret;
Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware1);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware1,
KeyModifiers.None, (int)KeysHardware.Hardware1);


Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware2);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware2,
KeyModifiers.None, (int)KeysHardware.Hardware2);

Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware3);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware3,
KeyModifiers.None, (int)KeysHardware.Hardware3);

Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware4);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware4,
KeyModifiers.None, (int)KeysHardware.Hardware4);
}
 
S

steel

I have found that when the Vitual KeyCode is 66-70, the system viewed
it as normal keyEvent, Not HotKey event. the related code:

public enum KeysHardware : int
{
Hardware1 = 66, //117,//
Hardware2 = 67, //118,//
Hardware3 = 68, //119,//
Hardware4 = 69, //120,//
Hardware5 = 71 // 121 //
}

public static void RegisterRecordKey(IntPtr hWnd)
{
bool Ret;
Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware1);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware1,
KeyModifiers.None, (int)KeysHardware.Hardware1);


Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware2);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware2,
KeyModifiers.None, (int)KeysHardware.Hardware2);

Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware3);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware3,
KeyModifiers.None, (int)KeysHardware.Hardware3);

Ret = UnregisterFunc1(KeyModifiers.None,
(int)KeysHardware.Hardware4);
Ret = RegisterHotKey(hWnd, (int)KeysHardware.Hardware4,
KeyModifiers.None, (int)KeysHardware.Hardware4);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top