 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
T-nm Guest
|
Posted: Tue Feb 28, 2006 10:48 pm Post subject: Using Keyboard LEDs for spectrum. |
|
|
This is pretty neat but only works with PS2 keyboards, sad.
It changes the leds without changing the real "state", only the leds for a winamp spectrum for example. Btw, samurize is very impressive.
I would like to know if someone could help me by making this program work for USB keyboards since autohotkey can control them.
http://www.samurize.com/modules/mydownloads/singlefile.php?cid=16&lid=1886 |
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1238
|
Posted: Thu Mar 02, 2006 6:01 am Post subject: |
|
|
I found this topic:
LEDs light in sequence? running light? LED chaser?
The only way to do it with AHK is to interfere with the actual state of the keys - so probably best to avoid toggling capslock in case you're typing (with corrupt's script there, you can just delete the lines that reference capslock). |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Mar 02, 2006 8:35 am Post subject: |
|
|
I still find it usefull as a progressbar replacement (eg. to visualize a datatransfer while using URLDownloadToFile).
| Quote: | | KeyLED [,On|Off,Sequence,Mode] | ! Not yet available.  |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Thu Mar 02, 2006 9:11 am Post subject: |
|
|
Adapted from "Miranda" code (referenced by evl):
note: tested with Windows XP, but should work with all versions of Windows?
update: 2006.03.02
| Code: | ; replace with "device instance id" from details page of keyboard device properties
device_instance_id = ACPI\PNP0303\4&61F3B4B&0
loop, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Control\DeviceClasses, 1, 1
{
if ( A_LoopRegName = "DeviceInstance" )
{
RegRead, value
if ( InStr( value, device_instance_id, false ) )
{
StringGetPos, ix, A_LoopRegSubKey, \##?#, R
StringTrimLeft, device, A_LoopRegSubKey, ix+5
device = \\.\%device%
break
}
}
}
if device =
{
MsgBox, %device_instance_id% not found!
ExitApp
}
h_device := DllCall( "CreateFile"
, "str", device
, "uint", 0
, "uint", 1 ; FILE_SHARE_READ
, "uint", 0
, "uint", 3 ; OPEN_EXISTING
, "uint", 0
, "uint", 0 )
MsgBox, [CreateFile] %A_Index% EL = %ErrorLevel%, LE = %A_LastError%, h_device = %h_device%
VarSetCapacity( output_actual, 4, 0 )
; -- input bit pattern --
; bit 0 = scroll lock
; bit 1 = num lock
; bit 2 = caps lock
input_size = 4
VarSetCapacity( input, input_size, 0 )
; -- EncodeInteger( 7, 1, &input, 2 ) --
input := Chr(1) Chr(1) Chr(7)
input := Chr(1)
input=
success := DllCall( "DeviceIoControl"
, "uint", h_device
, "uint", CTL_CODE( 0x0000000b ; FILE_DEVICE_KEYBOARD
, 2
, 0 ; METHOD_BUFFERED
, 0 ) ; FILE_ANY_ACCESS
, "uint", &input
, "uint", input_size
, "uint", 0
, "uint", 0
, "uint", &output_actual
, "uint", 0 )
MsgBox, [DeviceIoControl] EL = %ErrorLevel%, LE = %A_LastError%, success = %success%
VarSetCapacity( input, input_size, 0 )
success := DllCall( "DeviceIoControl"
, "uint", h_device
, "uint", CTL_CODE( 0x0000000b ; FILE_DEVICE_KEYBOARD
, 2
, 0 ; METHOD_BUFFERED
, 0 ) ; FILE_ANY_ACCESS
, "uint", &input
, "uint", input_size
, "uint", 0
, "uint", 0
, "uint", &output_actual
, "uint", 0 )
return
CTL_CODE( p_device_type, p_function, p_method, p_access )
{
return, ( p_device_type << 16 ) | ( p_access << 14 ) | ( p_function << 2 ) | p_method
} |
Last edited by shimanov on Fri Mar 03, 2006 1:16 am; edited 1 time in total |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Mar 02, 2006 9:19 am Post subject: |
|
|
Thank you Sir!  |
|
| Back to top |
|
 |
kapege.de
Joined: 07 Feb 2005 Posts: 186 Location: Munich, Germany
|
Posted: Thu Mar 02, 2006 9:37 am Post subject: |
|
|
W2000:
---------------------------
ACPI\PNP0303\4&61F3B4B&0 not found!
---------------------------
 _________________ Peter
Wisenheiming for beginners: KaPeGe (German only, sorry) |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Mar 02, 2006 9:43 am Post subject: |
|
|
| Quote: | ; replace with "device instance id" from details page of keyboard device properties
device_instance_id = ACPI\PNP0303\4&61F3B4B&0 |
| Quote: | | HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\DeviceClasses\{4afa3d53-74a7-11d0-be5e-00a0c9062857}\##?#ACPI#PNP0303#4&61f3b4b&0#{4afa3d53-74a7-11d0-be5e-00a0c9062857} | I've found this in the registry, but that won't help as there's (for me) no reference which specifies it as a/the keyboard (well, its kinda cryptic voodoo mambo jambo)  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Thu Mar 02, 2006 9:48 am Post subject: |
|
|
| Quote: | W2000:
---------------------------
ACPI\PNP0303\4&61F3B4B&0 not found! |
| Quote: | | ; replace with "device instance id" from details page of keyboard device properties | Wer lesen kann ist immer noch klar im Vorteil!
| Quote: | | Control Panel\System\Hardware\DeviceManager\Keyboards --> select Keyboard ---> Properties\Details\DeviceInstance ID |
|
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Thu Mar 02, 2006 9:59 am Post subject: |
|
|
It seems that the code works for you guys.
I am curious to know code compatibility on other Windows platforms. As I mentioned, the code is compatible with Windows XP. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Fri Mar 03, 2006 12:01 am Post subject: |
|
|
I tried to test on a Win98 PC, but I can't find the device_instance_id.
I've found e.g.:
| Quote: | Key= HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\DeviceClasses\{4d1e55b2-f16f-11cf-88cb-001111000030}\##.#0000000000000007#{4d1e55b2-f16f-11cf-88cb-001111000030}
Value= DeviceInstance HID\VID_045E&PID_0039\0000USB&VID_045E&PID_0039&INST_0 | But I couldn't figure out so far, which of the keys was related to the keyboard. I'm a bit scared of messing up my PC with the wrong values.
Tools I've found for id's are only working on Win2K and higher (e.g. from MS: devcon stack =keyboard). (DevCon uses apparently the missing SetUpAPI.dll)
| Shimanov code wrote: | input := Chr(1) Chr(1) Chr(7)
input := Chr(1)
input= | BTW, I don't understand what the 3 statements of "input" are for. It works also with only the one with the bit patterns.
Anyway, works great on XP machine, thanks  |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Mar 03, 2006 12:13 am Post subject: |
|
|
As already said/coded/commented by shimanov: replace with "device instance id" from details page of keyboard device properties
So check out: --> Control Panel --> System --> Hardware --> DeviceManager --> Keyboards --> select your Keyboard ---> Properties --> Details --> DeviceInstance ID. Bingo!
There might be a slight variation at the W9x Control Panel, but TBH I'm sure you'll make it  |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Fri Mar 03, 2006 12:50 am Post subject: |
|
|
| Peter wrote: | | I tried to test on a Win98 PC, but I can't find the device_instance_id. |
I don't have Windows 98, but we can continue your investigation with the following [passive] script below. Report the outcome, and I may be able to assist you further.
note: BoBo has understood my instruction correctly. You will be able to use the original code, if you can identify the active keyboard device from the device manager.
| Code: | loop, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Enum, 1, 1
{
if ( A_LoopRegName = "Class" )
{
RegRead, value
if ( InStr( value, "Keyboard", false ) )
{
RegRead, value2, %A_LoopRegKey%, %A_LoopRegSubKey%\Control, ActiveService
text = %text%`n%A_LoopRegSubKey%`n%value2%`n
}
}
}
MsgBox, %text% |
| Shimanov code wrote: | input := Chr(1) Chr(1) Chr(7)
input := Chr(1)
input= |
This code is the equivalent of
| shimanov wrote: | | ; -- EncodeInteger( 7, 1, &input, 2 ) -- |
| Quote: | | It works also with only the one with the bit patterns. |
| shimanov wrote: | ; -- input bit pattern --
; bit 0 = scroll lock
; bit 1 = num lock
; bit 2 = caps lock |
An LED is on when a bit is set, and, conversely, when a bit is cleared, the corresponding LED is off.
| Quote: | Anyway, works great on XP machine, thanks  |
At least it worked once. It's hard to predict undocumented, untested behavior. |
|
| Back to top |
|
 |
T-nm Guest
|
Posted: Fri Mar 03, 2006 12:59 am Post subject: |
|
|
Totally sorry for my noobness but what does this script do and does it work with USB keyboards?
And thanks a lot. |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Fri Mar 03, 2006 1:17 am Post subject: |
|
|
| T-nm wrote: | | what does this script do |
| Quote: | | It changes the leds without changing the real "state" |
| T-nm wrote: | | does it work with USB keyboards? |
Yes.
I have made a minor revision. Check the original post for the update. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Fri Mar 03, 2006 9:18 am Post subject: |
|
|
@BoBo: Yes I've found that out myself from Shimanov's code comment, how to find the device instance id. (BTW the details tab was already active in my XP, but is not (always) standard present in XP SP1 without some tweak, isn't it). So it was working in my Windows XP right away. (Tweaks seems in Win98 not working)
@Shimanov: I can check your request later, but it's not really important to get it working onWin98 (edit: result, see next post). I was only curious and responded to your question | Shimanov wrote: | | I am curious to know code compatibility on other Windows platforms |
Last edited by Peter on Fri Mar 03, 2006 12:58 pm; edited 1 time in total |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|