I found a solution. This works only on Windows, but then, I don’t know if other OS even have numlock keys, so if you target for other plattforms, you may have to #ifdef this code.
if( 0 == (GetKeyState(VK_NUMLOCK) & 1) )
{
INPUT input[2];
::ZeroMemory(input, sizeof(input));
input[0].type = input[1].type = INPUT_KEYBOARD;
input[0].ki.wVk = input[1].ki.wVk = VK_NUMLOCK;
input[1].ki.dwFlags = KEYEVENTF_KEYUP; // THIS IS IMPORTANT
::SendInput(2, input, sizeof(INPUT));
}