Can i control the 3 lights on my keyboard
Num.
Scroll.
Caps.
Keyboard Lights
Keyboard Lights
1.3AMD, 2x 256 sdr, 32 AGP
here it is.
Here it is. Found on thread:
viewtopic.php?t=4130&highlight=numlock
Try to use the search button. I always get that response. But ok. The code
in the thread was messy to copy because it was not in the code blocks.
Here it is to copy and paste. Written by PB! I just formatted it. Sorry if you
get angry of me copying your code, pb
here:
It works. You just take the procedure, and looks at the examples.
viewtopic.php?t=4130&highlight=numlock
Try to use the search button. I always get that response. But ok. The code
in the thread was messy to copy because it was not in the code blocks.
Here it is to copy and paste. Written by PB! I just formatted it. Sorry if you
get angry of me copying your code, pb

here:
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.
This:
Reminds me a car..
And this.. even.. more! http://www.gushh.com.ar/dls/cochefantastico.mid
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
And this.. even.. more! http://www.gushh.com.ar/dls/cochefantastico.mid
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
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
- np
Re: here it is.
> The code in the thread was messy to copy because it was not in the
> code blocks.
In the old PureBasic forums, we didn't have code blocks, which is why a
lot of old snippets here are not formatted. The posts were just copied
directly over to these forums -- without formatting, as expected.
> I just formatted it. Sorry if you get angry of me copying your code, pb
It's okay -- you gave credit where it's due, which is the right way to quote.
> code blocks.
In the old PureBasic forums, we didn't have code blocks, which is why a
lot of old snippets here are not formatted. The posts were just copied
directly over to these forums -- without formatting, as expected.

> I just formatted it. Sorry if you get angry of me copying your code, pb
It's okay -- you gave credit where it's due, which is the right way to quote.

LOL!! hey heres the final one: http://www.gushh.com.ar/dls/f-led.zip hahahah.. Now.. gotta find the movie.
Excellentdagcrack wrote:LOL!! hey heres the final one: http://www.gushh.com.ar/dls/f-led.zip hahahah.. Now.. gotta find the movie.


MfG
WOlFGaNgs
WolfgangS' projects http://www.schliess.net
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
Quotation of the month:
<p3hicy>oder ich hol mir so eine geile aus asien
<p3hicy>die ständig poppen will
<p3hicy>'n brötchen pro tag reicht doch
<p3hicy>die essen eh' nich so viel
This one is more fun 
I ran into strangeness with GetKeyState() when performed in the loop, it seemed to give false values.. So I just keep track of the key states myself so that when the program is done, the keys are returned to the state that they were in before the program started.

I ran into strangeness with GetKeyState() when performed in the loop, it seemed to give false values.. So I just keep track of the key states myself so that when the program is done, the keys are returned to the state that they were in before the program started.
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