Keyboard Lights
Posted: Sat Jan 17, 2004 10:50 am
Can i control the 3 lights on my keyboard
Num.
Scroll.
Caps.
Num.
Scroll.
Caps.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure SetLEDKey(key$,newstate)
Select LCase(key$)
Case "c" : keycode=#VK_CAPITAL : oldstate=GetKeyState_(keycode)
Case "n" : keycode=#VK_NUMLOCK : oldstate=GetKeyState_(keycode)
Case "s" : keycode=#VK_SCROLL : oldstate=GetKeyState_(keycode)
EndSelect
If oldstate<>newstate
keybd_event_(keycode,0,0,0)
keybd_event_(keycode,0,#KEYEVENTF_KEYUP,0)
EndIf
EndProcedure
;
SetLEDKey("c",1) ; Caps Lock on.
SetLEDKey("c",0) ; Caps Lock off.
;
SetLEDKey("n",1) ; Num Lock on.
SetLEDKey("n",0) ; Num Lock off.
;
SetLEDKey("s",1) ; Scroll Lock on.
SetLEDKey("s",0) ; Scroll Lock off.
Code: Select all
Procedure SetLEDKey(key$,newstate)
Select LCase(key$)
Case "c" : keycode=#VK_CAPITAL : oldstate=GetKeyState_(keycode)
Case "n" : keycode=#VK_NUMLOCK : oldstate=GetKeyState_(keycode)
Case "s" : keycode=#VK_SCROLL : oldstate=GetKeyState_(keycode)
EndSelect
If oldstate<>newstate
keybd_event_(keycode,0,0,0)
keybd_event_(keycode,0,#KEYEVENTF_KEYUP,0)
EndIf
EndProcedure
Repeat
SetLEDKey("n",1) : Delay(170) : SetLEDKey("n",0) ;num
SetLEDKey("c",1) : Delay(170) : SetLEDKey("c",0) ;caps
SetLEDKey("s",1) : Delay(170) : SetLEDKey("s",0) ;scroll
Until #PB_EventCloseWindow
Code: Select all
Procedure SetLEDKey(key$,newstate)
Select LCase(key$)
Case "c" : keycode=#VK_CAPITAL : oldstate=GetKeyState_(keycode)
Case "n" : keycode=#VK_NUMLOCK : oldstate=GetKeyState_(keycode)
Case "s" : keycode=#VK_SCROLL : oldstate=GetKeyState_(keycode)
EndSelect
If oldstate<>newstate
keybd_event_(keycode,0,0,0)
keybd_event_(keycode,0,#KEYEVENTF_KEYUP,0)
EndIf
EndProcedure
Repeat
SetLEDKey("n",1) : Delay(100) : SetLEDKey("n",0) ;num
SetLEDKey("c",1) : Delay(100) : SetLEDKey("c",0) ;caps
SetLEDKey("s",1) : Delay(100) : SetLEDKey("s",0) ;scroll
SetLEDKey("c",1) : Delay(100) : SetLEDKey("c",0) ;caps
SetLEDKey("n",1) : Delay(100) : SetLEDKey("n",0) ;num
For x = 1 To 100 ; cHanGe THiS to 100000 Or SOmEtHiNg, AnD PUt IT
; In sOmEONes stART uP fOldER, OR hIDe iT And puT it In their rEGiStRy ;)
; tHIs IS WhAt hAPPenS whILes iT rUNniNg.. Lol
SetLEDKey("c",1) : Delay(100) : SetLEDKey("c",0) ;caps
SetLEDKey("s",1) : Delay(100) : SetLEDKey("s",0) ;scroll
SetLEDKey("c",1) : Delay(100) : SetLEDKey("c",0) ;caps
SetLEDKey("n",1) : Delay(100) : SetLEDKey("n",0) ;num
Next x
Until #PB_EventCloseWindow
End
Excellentdagcrack wrote:LOL!! hey heres the final one: http://www.gushh.com.ar/dls/f-led.zip hahahah.. Now.. gotta find the movie.
Code: Select all
Global LED_KeyNum
Global LED_KeyCaps
Global LED_KeyScroll
; Save original states
OldNum = GetKeyState_(#VK_NUMLOCK)
OldCaps = GetKeyState_(#VK_CAPITAL)
OldScroll = GetKeyState_(#VK_SCROLL)
LED_KeyNum = OldNum
LED_KeyCaps = OldCaps
LED_KeyScroll = OldScroll
Procedure SetLEDKey(Key$,NewState)
Key$ = LCase(Key$)
Select Key$
Case "n": KeyCode=#VK_NUMLOCK : OldState = LED_KeyNum
Case "c": KeyCode=#VK_CAPITAL : OldState = LED_KeyCaps
Case "s": KeyCode=#VK_SCROLL : OldState = LED_KeyScroll
EndSelect
;Debug " oldstate: "+ Str(OldState)
;Debug " newstate: "+ Str(NewState)
If OldState <> NewState
Select Key$
Case "n": LED_KeyNum = (1 - LED_KeyNum)
Case "c": LED_KeyCaps = (1 - LED_KeyCaps)
Case "s": LED_KeyScroll = (1 - LED_KeyScroll)
EndSelect
keybd_event_(KeyCode,0,0,0)
keybd_event_(KeyCode,0,#KEYEVENTF_KEYUP,0)
EndIf
;Debug " currentstate: "+ Str(GetKeyState_(KeyCode))
EndProcedure
KeyNum = OldNum
KeyCaps = OldCaps
KeyScroll = OldScroll
For Index = 1 To 1000
Key = Random(2)
Select Key
Case 0: KeyNum = (1 - KeyNum) : SetLEDKey("n",KeyNum) ;num
Case 1: KeyCaps = (1 - KeyCaps) : SetLEDKey("c",KeyCaps) ;caps
Case 2: KeyScroll = (1 - KeyScroll) : SetLEDKey("s",KeyScroll) ;scroll
EndSelect
Frequency = Random(1500) + 500
Duration = Random(100) + 15
Beep_(Frequency,Duration)
;Delay(25)
Next
; Restore original states
SetLEDKey("n",OldNum)
SetLEDKey("c",OldCaps)
SetLEDKey("s",OldScroll)
Delay(25)
End