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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.