Jump to content

Controlling caps/num/scoll lock LEDs

- - - - -

  • Please log in to reply
2 replies to this topic

#1
ThunderGraduate

ThunderGraduate

    Newbie

  • Members
  • Pip
  • 1 posts
Hi All!

Does anyone know if there is a way to control the caps/num/scroll lock LEDs on a keyboard without actually activating caps/num/scroll lock?

For example I never use scroll lock or num lock and think it would be awesome if I could hook them up to any email notification program and make 'em light up or blink! :)
I've only found software like this: Keyboard LED Control-Set Numlock, Caps Lock and Scroll Lock indicator lights always on, always off or flash that does nothing but tell the computer a certain key was pushed. Makes it difficult to type or whatever while it's just changing the state of for example caps lock the entire time..
So how do I manipulate the caps/num/scroll lock LEDs without having the computer thinking I've pushed one of the keys? :confused:

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
It would not be possible without writing your own (signed) driver which would be a hard task at that. My keyboard lights work without being in a system with a keyboard driver, so atleast this standard keyboard does not even tell the OS that the light is on, it is independent.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 763 posts
If you mean to control the caps/num/scroll lock LEDs without actually pressing the respected keys then you can simulate the keystrokes with codes. But the computer still thinks that you have pushed the button. In windows you can use api keybd_event for this.

Here Delphi codes to toggle the LEDs by simulating the keystrokes.


procedure ToggleLockKey(const ACode: Integer);

begin

  keybd_event(ACode, MapVirtualkey(ACode, 0 ), KEYEVENTF_EXTENDEDKEY, 0);

  keybd_event(ACode, MapVirtualkey(ACode, 0 ), KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);

end;


procedure SetLockKey(const ACode: Integer; const ADown: Boolean);

begin

  if Odd(GetAsyncKeyState(ACode)) <> ADown then

    ToggleLockKey(ACode);

end;


procedure ToggleNumLockState;

begin

  ToggleLockKey(VK_NUMLOCK);

end;


procedure ToggleScrollLockState;

begin

  ToggleLockKey(VK_SCROLL);

end;


procedure ToggleCapsLockState;

begin

  ToggleLockKey(VK_CAPITAL);

end;



Back in my assembly class, I recall there is a DOS interrupt (back then DOS was still popular) to send keyboard state (to known address of keyboard I/O port). I don't know if you still be able to do that under current OS (being they are more protective).




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users