Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Turning On/Off CapsLock & NumLock

Helo everybody and thank you for viewing this message!

Does anybody know how to turn on/off CapsLock and NumLock?
Is there any source code available?
If there is, our you know how to do it, please help me!

Thank you for reading this message!
Goodbye!

Comments

  • ComboyComboy Member Posts: 4
    [b][red]This message was edited by Comboy at 2003-4-4 4:43:6[/red][/b][hr]
    Hello,
    It's the first hour I'm visiting this messageboard, so I couldn't answer you sooner! and I saw nobody has answered this yet. It's very late right now (about 6 months) but I decided to post the answer.
    First add this:
    ***
    type
    TKeyType = (ktCapsLock, ktNumLock, ktScrollLock);
    ***

    Then add this procedure to implementation:
    ***
    procedure TurnOnOff(KeyCode: TKeyType; bOn: Boolean);
    var
    KBState: TKeyboardState;
    Code: Byte;
    begin
    case KeyCode of
    ktScrollLock: Code := VK_SCROLL;
    ktCapsLock: Code := VK_CAPITAL;
    ktNumLock: Code := VK_NUMLOCK;
    end;
    GetKeyboardState(KBState);
    if (Win32Platform = VER_PLATFORM_WIN32_NT) then
    begin
    if Boolean(KBState[Code]) <> bOn then
    begin
    keybd_event(Code,
    MapVirtualKey(Code, 0),
    KEYEVENTF_EXTENDEDKEY, 0);
    keybd_event(Code, MapVirtualKey(Code, 0),KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
    end;
    end
    else
    begin
    KBState[Code] := Ord(bOn);
    SetKeyboardState(KBState);
    end;
    end;
    ***

    Well, now
    TurnOnOff(ktCapsLock{write the light you wanna turn on/off}, True{to turn it on write true and to turn it off write false} );

    Have fun,

    Comboy.
    _______________________________
    : Helo everybody and thank you for viewing this message!
    : Does anybody know how to turn on/off CapsLock and NumLock?
    : Is there any source code available?
    : If there is, our you know how to do it, please help me!
    :
    : Thank you for reading this message!
    : Goodbye!
    _______________________________


  • haubihaubi Member Posts: 2
    : [b][red]This message was edited by Comboy at 2003-4-4 4:43:6[/red][/b][hr]
    : Hello,
    : It's the first hour I'm visiting this messageboard, so I couldn't answer you sooner! and I saw nobody has answered this yet. It's very late right now (about 6 months) but I decided to post the answer.
    : First add this:
    : ***
    : type
    : TKeyType = (ktCapsLock, ktNumLock, ktScrollLock);
    : ***
    :
    : Then add this procedure to implementation:
    : ***
    : procedure TurnOnOff(KeyCode: TKeyType; bOn: Boolean);
    : var
    : KBState: TKeyboardState;
    : Code: Byte;
    : begin
    : case KeyCode of
    : ktScrollLock: Code := VK_SCROLL;
    : ktCapsLock: Code := VK_CAPITAL;
    : ktNumLock: Code := VK_NUMLOCK;
    : end;
    : GetKeyboardState(KBState);
    : if (Win32Platform = VER_PLATFORM_WIN32_NT) then
    : begin
    : if Boolean(KBState[Code]) <> bOn then
    : begin
    : keybd_event(Code,
    : MapVirtualKey(Code, 0),
    : KEYEVENTF_EXTENDEDKEY, 0);
    : keybd_event(Code, MapVirtualKey(Code, 0),KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
    : end;
    : end
    : else
    : begin
    : KBState[Code] := Ord(bOn);
    : SetKeyboardState(KBState);
    : end;
    : end;
    : ***
    :
    : Well, now
    : TurnOnOff(ktCapsLock{write the light you wanna turn on/off}, True{to turn it on write true and to turn it off write false} );
    :
    : Have fun,
    :
    : Comboy.
    : _______________________________
    : : Helo everybody and thank you for viewing this message!
    : : Does anybody know how to turn on/off CapsLock and NumLock?
    : : Is there any source code available?
    : : If there is, our you know how to do it, please help me!
    : :
    : : Thank you for reading this message!
    : : Goodbye!
    : _______________________________
    :
    :
    :

  • haubihaubi Member Posts: 2
    [b][red]This message was edited by haubi at 2003-6-14 2:15:7[/red][/b][hr]
    : : [b][red]This message was edited by Comboy at 2003-4-4 4:43:6[/red][/b][hr]
    : : Hello,
    : : It's the first hour I'm visiting this messageboard, so I couldn't answer you sooner! and I saw nobody has answered this yet. It's very late right now (about 6 months) but I decided to post the answer.
    : : First add this:
    : : ***
    : : type
    : : TKeyType = (ktCapsLock, ktNumLock, ktScrollLock);
    : : ***
    : :
    : : Then add this procedure to implementation:
    : : ***
    : : procedure TurnOnOff(KeyCode: TKeyType; bOn: Boolean);
    : : var
    : : KBState: TKeyboardState;
    : : Code: Byte;
    : : begin
    : : case KeyCode of
    : : ktScrollLock: Code := VK_SCROLL;
    : : ktCapsLock: Code := VK_CAPITAL;
    : : ktNumLock: Code := VK_NUMLOCK;
    : : end;
    : : GetKeyboardState(KBState);
    : : if (Win32Platform = VER_PLATFORM_WIN32_NT) then
    : : begin
    : : if Boolean(KBState[Code]) <> bOn then
    : : begin
    : : keybd_event(Code,
    : : MapVirtualKey(Code, 0),
    : : KEYEVENTF_EXTENDEDKEY, 0);
    : : keybd_event(Code, MapVirtualKey(Code, 0),KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
    : : end;
    : : end
    : : else
    : : begin
    : : KBState[Code] := Ord(bOn);
    : : SetKeyboardState(KBState);
    : : end;
    : : end;
    : : ***
    : :
    : : Well, now
    : : TurnOnOff(ktCapsLock{write the light you wanna turn on/off}, True{to turn it on write true and to turn it off write false} );
    : :
    : : Have fun,
    : :
    : : Comboy.
    : : _______________________________
    : : : Helo everybody and thank you for viewing this message!
    : : : Does anybody know how to turn on/off CapsLock and NumLock?
    : : : Is there any source code available?
    : : : If there is, our you know how to do it, please help me!
    : : :
    : : : Thank you for reading this message!
    : : : Goodbye!
    : : _______________________________
    : :
    : : Thank you Comboy for good advice. Unfortunately, the message has
    : : arrived in garbled form. For all who also may have found some
    : : difficulty in using the program: After Boolean KBState 'Code'
    : : must be inserted in square brakets. The same holds true seven
    : : lines below.



  • FactorSoftwareFactorSoftware Member Posts: 19
    Sorry for not thanking you sooner for your reply!
    Your code work's fine!
    Your a life saver! Thx again... :-)
Sign In or Register to comment.