API - capsLock, numlock e scrolllock |
Top Previous Next |
// Para SCROLLLOCK = 145 (no lugar de 20, e 1 no lugar de Vk_Insert) // Para NUMLOCK = 144 (no lugar de 20, e 1 no lugar de Vk_Insert)
Procedure LigaCaps; var KeyState : TKeyBoardState; begin GetKeyboardState(KeyState); KeyState[20] := VK_INSERT; SetKeyBoardState(KeyState); end;
Procedure DesligaCaps; var KeyState : TKeyBoardState; begin GetKeyboardState(KeyState); KeyState[20] := 0; SetKeyBoardState(KeyState); end;
// Abaixo, se está ligado, desliga e retorna FALSE // se está desligado, liga e retorna TRUE
Function AlternaCaps:Boolean; var KeyState : TKeyBoardState; begin GetKeyboardState(KeyState); If GetKeyState(20) <> 0 then KeyState[20] := 0 // Estava ligado, desliga else KeyState[20] := VK_INSERT; // Estava desligado, liga Result := GetKeyState(20) = 0; SetKeyBoardState(KeyState); // Acende a luzezinha end;
-------------------------------- OUTRO ----------------------------------------- // Pegando o estado das teclas CAPS, NUMLOCK e SCROL
function CapsLockLigada : Boolean; begin Result := (GetKeyState(VK_CAPITAL) and 1) <> 0; end;
function NumLockLigada : Boolean; begin Result := (GetKeyState(VK_NUMLOCK) and 1) <> 0; end;
function ScrollLockLigada : Boolean; begin Result := (GetKeyState(VK_SCROLL) and 1) <> 0; end; |