Решение:
procedure SetNumLock(bState: Boolean);
var
KeyState: TKeyboardState;
begin
GetKeyboardState(KeyState);
if ((bState) and (not ((KeyState[VK_NUMLOCK] and 1) = 1))
or ((not (bState)) and ((KeyState[VK_NUMLOCK] and 1) = 1))) then
// имитация нажатия клавиши
keybd_event(VK_NUMLOCK, $45, (KEYEVENTF_EXTENDEDKEY or 0), 0);
// имитация отпускания клавиши
keybd_event(VK_NUMLOCK, $45, (KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP), 0);
SetKeyboardState(KeyState);
end;
Для других клавиш заменяйте VK_NUMLOCK.[News Group]