Can someone help me with this? I No matter what I do, when I press F9, the message box pops up showing F9, But when I press F10, the message box for F9 pops up.. Is it because MSG msg and MSG msg2 are the same?? How do I fix this, Im not very good at it :S
Basically I want to tell which Global hotkey was pressed.
if (RegisterHotKey(NULL,1,0x4000,0x78)) //F9 Key
{
MessageBox::Show("SmartChat -- Registered HotKey: F9");
}
if (RegisterHotKey(NULL,2,0x4000,0x79)) //F10 Key
{
MessageBox::Show("Exit -- Registered Hotkey: F10");
}
MSG msg = {0};
MSG msg2 = {0};
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
if(msg.message == WM_HOTKEY)
{
MessageBox::Show("F9");
}
break;
}
while (GetMessage(&msg2, NULL, 0, 0) != 0)
{
if(msg.message == WM_HOTKEY)
{
MessageBox::Show("F10");
}
break;
}
P.S. I had it working when I put them hotkeys and messages in two separate threads.. that way one thread monitors one key, the next monitors another key.. but it lags me a lot more than when I only had 1 thread. Current program has 4 threads (BackgroundWorkers) and it lags me so bad! So Im trying to reduce it by putting 99% of the code in one thread.