I've got a program written in C++ and running on windows. I allow the user to keybind the CAPSLOCK key so it would be nice if, every time they pressed it, they weren't also toggling their CAPSLOCK state.
I've found no way to "capture" the CAPSLOCK message in order to prevent it from being registered by windows. It seems like by the time I get a WM_KEYDOWN message, the indicator light on my keyboard has already switched.
I did find this suggested code:
keybd_event( VK_CAPITAL, 0x3a, KEYEVENTF_EXTENDEDKEY, 0 );
keybd_event( VK_CAPITAL, 0x3a, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
But, it doesn't work. It kinda caused the indicator light to flicker, and doesn't seem to affect the CAPSLOCK state at all.
Try it in reverse order:
keybd_event( VK_CAPITAL, 0x3a, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
keybd_event( VK_CAPITAL, 0x3a, KEYEVENTF_EXTENDEDKEY, 0 );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With