1

I tried something with WM_SYSKEYDOWN, and WM_SYSKEYUP for Keyboard-Input.

Here is the significant codepart.

        case WM_SYSKEYDOWN:
            if (wParam == VK_MENU)      // VK_MENU = 18 = alt keys
            {
                if (!(lParam & (1 << 30)))
                {
                    std::cout << "Pressed left alt key" << std::endl;
                }   
            };
            break;

        case WM_SYSKEYUP:
            if (wParam == VK_MENU)      // VK_MENU = 18 = alt keys
            {
                        std::cout << "Released left alt key" << std::endl;
            };
            break;

I tried to print one string one time if I pressed the button, and printing the other string on releasing the key.

Releasing works, but pressing responses just one time each 2 presses.

if (!(lParam & (1 << 30)))

This line should interrupt frequently posting the string again.

I don't get it why... , but I hope do.

Thanks in advance!

4

1 回答 1

0

我没有使用我发现的这个功能。

if (GetAsyncKeyState(VK_LSHIFT) & 0x8000)
{
// Button pressed!
}

效果很好:D

于 2016-07-15T19:37:34.777 回答