Board index » delphi » Num Lock / Caps Lock / Scroll Lock

Num Lock / Caps Lock / Scroll Lock

Has anyone an idea how I could check the state of the NumLock,
CapsLock and ScrollLock keys ? TShiftState doesnt carry this
information, and in the Delphi Help-File I didn't find anything about
the subject.

Thanks for your help !

Thomas

(101615.1...@compuserve.com)

 

Re:Num Lock / Caps Lock / Scroll Lock


Quote
m...@spectraweb.ch (Thomas Marti) wrote:
> Has anyone an idea how I could check the state of the NumLock,
> CapsLock and ScrollLock keys ? TShiftState doesnt carry this
> information, and in the Delphi Help-File I didn't find anything about
> the subject.

Use the API function GetKeyState().  For example, to test NumLock, you would
do something like:

if Odd(GetKeyState(VK_NUMLOCK)) then
  ShowMessage('NumLock is on')
else
  ShowMessage('NumLock is off');

Use VK_CAPTIAL for Caps Lock and VK_SCROLL for Scroll Lock.

Regards,
Brad
bstow...@pobox.com
Free Delphi Stuff:  http://www.pobox.com/~bstowers/delphi/

Re:Num Lock / Caps Lock / Scroll Lock


In article d...@mephisto.imp.ch, m...@spectraweb.ch (Thomas Marti) writes:

Quote
>Has anyone an idea how I could check the state of the NumLock,
>CapsLock and ScrollLock keys ? TShiftState doesnt carry this
>information, and in the Delphi Help-File I didn't find anything about
>the subject.

>Thanks for your help !

>Thomas

>(101615.1...@compuserve.com)

Take a look at the GetKeyBoardState() function.  Something like:

  var
    KeyboardStat: TKeyboardState;
  begin
  GetKeyBoardState(KeyboardState);
  if KeyboardState[VK_CONTROL] = ... then { check for bit 0 }
  ...
  end;

I hope this is enough to get you started.

Best regards,
Michael Vincze
vin...@ti.com

Re:Num Lock / Caps Lock / Scroll Lock


In article <4rdijn$...@mephisto.imp.ch>, m...@spectraweb.ch says...

Quote
> Has anyone an idea how I could check the state of the NumLock,
> CapsLock and ScrollLock keys ? TShiftState doesnt carry this
> information, and in the Delphi Help-File I didn't find anything about
> the subject.

 Hmmm...I am almost sure I saw a freeware component on one of the
archives which did just that....can't remember where though.

 Scan the sunsite archives or the delphin station...you  might find it

Other Threads