Jump to content
monoceres

Control the Keyboard's leds

Recommended Posts

monoceres

Hi!

Like I promised yesterday here's an UDF that changes the state of the keyboard's leds (Caps lock, Num lock & Scroll lock).

You tell the UDF which buttons to lit/unlit by BitOR'ing (or plussing ) the constants in the top of the script.

Keyboard_LED_Controller.au3

example.au3

Enjoy! :mellow:


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
JRSmile

i was really supprised that this is possible, downloaded it as fast as i could and had sadly to see that it does not work with logitech G15 keyboards...


$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])))''Chr("a")&"HI"Next;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)

Share this post


Link to post
Share on other sites
GtaSpider

Same at mine G15v2 :mellow:

But tried it on other keyboard and it works. Very nice man.

Nothing is impossible with AutoIt know i think :(

(Except of acces to .NET^^)

Spider


www.AutoIt.de - Moderator of the German AutoIt Froum

Share this post


Link to post
Share on other sites
Kreatorul

Man you always write the coolest stuff. This would make a good prank for Fools Day for my sister. It even works on my laptop(capslock only).

Share this post


Link to post
Share on other sites
monoceres

Thanks all :mellow:

For those of you that the script doesn't work for:

I think that the problem is that I assume that the default windows driver is used or something.

Could you please post what's inside the reg key HKEY_LOCAL_MACHINE\HARDWARE\DeviceMap\KeyboardClass

:(


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
TehWhale

Ugh, doesn't work for me.

Heres what in there:

Default (Value Not Set)

\Device\KeyboardClass0 - - - - - - - \REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\kbdclass

\Device\KeyboardClass1 - - - - - - - - \REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\kbdclass

Share this post


Link to post
Share on other sites
monoceres

Ugh, doesn't work for me.

Heres what in there:

Default (Value Not Set)

\Device\KeyboardClass0 - - - - - - - \REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\kbdclass

\Device\KeyboardClass1 - - - - - - - - \REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\kbdclass

Hmm, try changing "\Device\KeyboardClass0" to "\Device\KeyboardClass1" in the _OpenKeyboard func.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
TehWhale

Hmm, try changing "\Device\KeyboardClass0" to "\Device\KeyboardClass1" in the _OpenKeyboard func.

Nope. Still doesn't work! I was looking forward to this too. :mellow:

Share this post


Link to post
Share on other sites
monoceres

Nope. Still doesn't work! I was looking forward to this too. :mellow:

Hmm, too bad. I'll do some research and hopefully I will find a way to send this data to whatever keyboards.


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
TehWhale

Hmm, too bad. I'll do some research and hopefully I will find a way to send this data to whatever keyboards.

If it helps, i'm using the standard Alienware keyboard.

Share this post


Link to post
Share on other sites
monoceres

Ok, I've got something.

Try replacing "\Device\KeyboardClass0" to your keyboard's "Physical Device Object Name", which can be found in device manager:

Posted ImagePosted Image

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
TehWhale

DllCall("Kernel32.dll","int","DefineDosDeviceW","dword",$DDD_RAW_TARGET_PATH,"wstr","Keybd","wstr","\Device\000000c9")

It says: \Device\000000c9 is my physical device object name, but its yet to work. :mellow:

Share this post


Link to post
Share on other sites
monoceres

DllCall("Kernel32.dll","int","DefineDosDeviceW","dword",$DDD_RAW_TARGET_PATH,"wstr","Keybd","wstr","\Device\000000c9")

It says: \Device\000000c9 is my physical device object name, but its yet to work. :mellow:

Damn, I really thought that would work, well I'm out of ideas. Google doesn't give you that much info either. I'll try asking at SysInternals forum tomorrow, they usually are pretty good with this low-level stuff.

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
TehWhale

Damn, I really thought that would work, well I'm out of ideas. Google doesn't give you that much info either. I'll try asking at SysInternals forum tomorrow, they usually are pretty good with this low-level stuff.

:( I'll have to wait. :mellow:

Share this post


Link to post
Share on other sites
Andreik

Nice work monoceres. :mellow::(


When the words fail... music speaks

Share this post


Link to post
Share on other sites
Wessi

Hello,

nothing happens here, why?

First of all, thanx for this interesting code, monoceres.

To get a handle for "normal" keyboards(PS/2) in KeyboardClass0 is easy, but getting a handle for HIDs(USB) is difficult.

There a two different ways the OS handles such keyboards, native HID(with own driver) and/or emulated("USB Generic Parent Driver"/usbccgp).

Maybe its possible to detect USB-keyb over this service or get the right keyb over the handler from kbdclass.sys over IRP_MJ_READ

Maybe this helps:

http://www.codeproject.com/KB/recipes/keystroke-hook.aspx #4.0

http://mamedev.org/source/src/osd/windows/ledutil.c.html

or with a dll like this:

http://code.google.com/p/csharp-usb-hid-driver/downloads/list

explained here:

http://www.florian-leitner.de/index.php/2007/08/03/hid-usb-driver-library/

Share this post


Link to post
Share on other sites
dariel

hi, i cant make this work, the _OpenKeyboard() func return me 0x0000000000000114 so i think he is getting the keyboard handle well, so the error must be in the _KeyboardSetLed() func, any ideas?, thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.