Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Encender y apagar leds del teclado. (https://www.clubdelphi.com/foros/showthread.php?t=65130)

matabyte 23-11-2009 14:56:33

Encender y apagar leds del teclado.
 
Buenas, como siempre con una pregunta :p

Sabéis alguna forma de encender en Delphi los LEDs del teclado? Me refiero a los "Scroll Lock", "Caps Locks" y el "Num Lock".

Gracias por la ayuda ;)

matabyte 23-11-2009 15:52:16

Me autorespondo y dejo la solución por si alguien también tiene el mismo problema ;)

Código Delphi [-]
procedure ToggleNumLock(tecla:integer);
var
   KeyState: TKeyboardState;
begin
   //note: Use VK_CAPITAL for Caps Lock

   GetKeyboardState(KeyState) ;

   //simulate key events (down + up)
   if (KeyState[tecla] = 0) then
   begin
     Keybd_Event(tecla, 1, KEYEVENTF_EXTENDEDKEY or 0, 0) ;
     Keybd_Event(tecla, 1, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0) ;
   end
   else
   begin
     Keybd_Event(tecla, 0, KEYEVENTF_EXTENDEDKEY or 0, 0) ;
     Keybd_Event(tecla, 0, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0) ;
   end;
end;

procedure ParpadearTimer(Sender: TObject);
begin
  parpadear.Enabled:=false;
     if radionumlock.Checked then ToggleNumLock(VK_NUMLOCK);
     if radiomayusculas.Checked then ToggleNumLock(VK_CAPITAL);
     if radioscroll.Checked then ToggleNumLock(VK_SCROLL);
  parpadear.Enabled:=true;
end;

rgstuamigo 23-11-2009 16:19:58

Yo no veo diferencia entre esto
Código Delphi [-]
Keybd_Event(tecla, 1, KEYEVENTF_EXTENDEDKEY or 0, 0) ;
Keybd_Event(tecla, 1, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0) ;
y esto
Código Delphi [-]
Keybd_Event(tecla, 0, KEYEVENTF_EXTENDEDKEY or 0, 0) ;
Keybd_Event(tecla, 0, KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0) ;
Cual es la diferencia? Y por que el if?:confused:.
Otra observacion que veo es que estas deshabilitando tu Timer antes de ejecutar las demas lineas, lo cual implica que nunca se ejecutaran,
Te funciona asi??:confused:.
Saludos...:)


La franja horaria es GMT +2. Ahora son las 10:13:09.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi