0

I am proficient in c++, however i know almost nothing regarding the windows api.

What i want my program to do is intercept the CAPSLOCK key and ignore it (as if it weren't pressed in the first place)
If the user presses SHIFT+CAPSLOCK it would toggle capslock on or off.

I assume the program would use some api to hook capslock and if shift was not pressed before, trash one of the key pressed flags?? I have googled and honestly have no idea how i would do this.

I have tried this, but it seems stupid and it dosen't work all the time.

bool loop1 = true;
    
    while (true)
    {
          if (GetAsyncKeyState(VK_CAPITAL))
          {
             Sleep(15);
             //Turn on Caps Lock:
             keybd_event(VK_CAPITAL, 0, KEYEVENTF_EXTENDEDKEY | 0, 0);
             //Turn off Caps Lock:
             keybd_event(VK_CAPITAL, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
             Sleep(15);
          }
    }

Thanks

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by ixmike88
0

i don't know anything about the actual "ignoring" process of it but you may want another check that checks if shift is being held down while vk_capital is

if( GetAsyncKeyState( VK_CAPITAL ) && !GetAsyncKeyState( VK_SHIFT ) )
{
   //ignore key code here
}

i also am not sure if getasynckeystate() applies to the entire os or just if the program is in focus

Edited by ixmike88: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.