 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
kapege.de
Joined: 07 Feb 2005 Posts: 188 Location: Munich, Germany
|
Posted: Fri Mar 03, 2006 8:40 am Post subject: |
|
|
| BoBo wrote: | | 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 |
|
I've to do something else @ work also. So I did a ctrl-click into that very code, ctrl-c, Alt-Tab, Paste into the editor, run, Error, ctrl-c, paste it in my message, working, working, working...
Therefore I've no admin rights @ work w/ my w2000 if no access to that panel. In the German version I've:
"Allgemein, Treiber, Ressourcen, Energieverwaltung"
Within "Treiber" I have "Treiberdetails" but there's only a file mentioned:
...\i8042prt.sys
Have to try it @home later. _________________ Peter
Wisenheiming for beginners: KaPeGe (German only, sorry) |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Mar 03, 2006 10:44 am Post subject: |
|
|
@ To whom it may concern | Quote: | Go Directly to Device Manager
The Device Manager is one of Windows' most useful diagnostic tools. It lets you see all of the devices attached to your computer, and which resources they are each using.
Windows 95/98/Me
You can open Device Manager by double-clicking on the System icon in Control Panel, and choosing the Device Manager tab. It is also accessible by right-clicking on My Computer, selecting Properties, and selecting the Device Manager tab. Getting to the Device Manager this can require up to six mouse clicks, but there is an easier way.
Open an Explorer window, and select your Start Menu folder (under your Windows directory). It doesn't have to go here, but it's as good a place as any.
Select New and then Shortcut from the File Menu.
In the field labelled Command Line, type C:\WINDOWS\CONTROL.EXE Sysdm.cpl, System,1 (replace C:\WINDOWS\ with your Windows directory, if different).
Click Next, type Device Manager for the name of this shortcut, and press Finish when you're done.
There will now be a shortcut directly to Device Manager in your Start Menu.
Windows 2000/XP
You can open Device Manager by double-clicking on the System icon in Control Panel, choosing the Hardware tab, and clicking Device Manager.
Fortunately, Device Manager can be more easily run by launching devmgmt.msc - just create a shortcut to the file (as described above), and launch it at any time. |
|
|
| Back to top |
|
 |
T-nm Guest
|
Posted: Fri Mar 03, 2006 12:01 pm Post subject: |
|
|
I see this too: HID\VID_045E&PID_0039\0000USB&VID_045E&PID_0039&INST_0
And the script ends when started. And how do we use this script btw ?
Man I feel so noob. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Fri Mar 03, 2006 12:16 pm Post subject: |
|
|
@Shimanov:Here is the result of your script for Win98:
First PC result (4.10.1998): <nothing> (edit: added version)
Second PC result (98SE 4.10.222A): <nothing> (edit: added result)
Yeah right, nothing for both . (On some XP machine it gives 3 results. edit: on my XP PC just 1 result)
I was afraid it is in Win98 at some other registry key (somewhere HK_Dyn_Data?) (PS: As I told, it's not really an important matter for me)
Last edited by Peter on Fri Mar 03, 2006 5:01 pm; edited 1 time in total |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Mar 03, 2006 12:23 pm Post subject: |
|
|
Using this | Code: | | Run, cmd /k devcon find =keyboard | will deliver something (or similar) like that ... | Quote: | ACPI\PNP0303\4&61F3B4B&0 : Standard 101/102-Key or Microsoft Natural PS/2 Keyboard
1 matching device(s) found. | [More][Download] |
|
| Back to top |
|
 |
Greg
Joined: 22 Dec 2005 Posts: 246
|
Posted: Fri Mar 03, 2006 3:05 pm Post subject: |
|
|
On Win2k:
| Quote: | | ACPI\PNP0303\4&61F3B4B&0 not found! |
|
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Fri Mar 03, 2006 3:21 pm Post subject: |
|
|
@ Greg
take DevCon from the link I gave above. Run it, using the command I gave above. If you have a keyboard connected to your box and you use the parameter find = keyboard with DevCon (check out the link I gave above) I assume you will get the info you search for ... |
|
| Back to top |
|
 |
Greg
Joined: 22 Dec 2005 Posts: 246
|
Posted: Fri Mar 03, 2006 3:31 pm Post subject: |
|
|
@ BoBo
I can't from work. I have Win2k at home; I'll try later. |
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1239
|
Posted: Fri Mar 10, 2006 11:02 pm Post subject: |
|
|
Has anyone turned this code into a more usable form such as a simple function that could be called to set the desired LED states? Also, is it possible to return the LEDs to their "true" state (e.g. the script turns off all 3 LEDs when the NumLock is actually on - but I'm presuming the script was supposed to do that). I've tried playing with the code myself, but I have no clue what I'm doing
A nice simple use I found was turning off the numlock light on my laptop when using an external keyboard - now I don't have a green light constantly distracting me from my inability to program  |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Fri Mar 10, 2006 11:20 pm Post subject: |
|
|
I hope this is useful enough.
[Edit: Changed the Cmd options to more logical and useful, and made correction according to Shimanov's edited script]
| Code: | If !KeyboardLED("","init") ;Search first time for the RegKey
MsgBox, Can't find device
else
{
KeyboardLED("5","switch") ;switches the LED's ScrollLock and CapsLock on, and NumLock off
Sleep, 2000
KeyboardLED("0","on") ;All LED('s) according to keystate (Cmd= on or off)
Sleep, 2000
KeyboardLED("1","switch") ;switches the ScrollLock LED on, and others off
Sleep, 2000
KeyboardLED("0","off") ;All LED('s) according to keystate (Cmd= on or off)
Loop, 25
{
KeyboardLED("4","on") ;only CapsLock LED on
Sleep, 100
KeyboardLED("4","off") ;only CapsLock LED off
Sleep, 100
}
}
KeyboardLED("0","off") ;All LED('s) according to keystate (Cmd= on or off)
Return
KeyboardLED(LEDvalue, Cmd)
;Original code for keyboard LED control is from Shimanov
;http://www.autohotkey.com/forum/viewtopic.php?t=8372&postdays=0&postorder=asc&start=0
; !!!replace with your "device instance id" from details page of keyboard device properties
;LEDvalue: ScrollLock= 1, NumLock= 2, CapsLock= 4
{
Static device
If Cmd= init
{
device_instance_id = ACPI\PNP0303\3&2411e6fe&0 ;your own "device instance id"
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!
Return false
}
else
Return true
}
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_size = 4
VarSetCapacity( input, input_size, 0 )
If Cmd= switch ;switches every LED according to LEDvalue
KeyLED:= LEDvalue
If Cmd= on ;forces all choosen LED's to ON (LEDvalue= 0 ->LED's according to keystate)
KeyLED:= LEDvalue | (GetKeyState("ScrollLock", "T") + 2*GetKeyState("NumLock", "T") + 4*GetKeyState("CapsLock", "T"))
If Cmd= off ;forces all choosen LED's to OFF (LEDvalue= 0 ->LED's according to keystate)
{
LEDvalue:= LEDvalue ^ 7
KeyLED:= LEDvalue & (GetKeyState("ScrollLock", "T") + 2*GetKeyState("NumLock", "T") + 4*GetKeyState("CapsLock", "T"))
}
; -- EncodeInteger( KeyLED, 1, &input, 2 ) --
; -- input bit pattern (KeyLED)--
;bit 0 = scroll lock
;bit 1 = num lock
;bit 2 = caps lock
input := Chr(1) Chr(1) Chr(KeyLED)
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%
}
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 Peter on Sat Mar 11, 2006 12:42 pm; edited 1 time in total |
|
| Back to top |
|
 |
evl
Joined: 24 Aug 2005 Posts: 1239
|
Posted: Fri Mar 10, 2006 11:42 pm Post subject: |
|
|
Thanks, that seems to more or less do it, but is it possible to set all 3 states with a single call? (I think it should be, judging by the original code, but that's a bit of a guess ). I should be able to follow the code a bit more easily now anyhow, thanks. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Sat Mar 11, 2006 12:24 am Post subject: |
|
|
You have to fill in the right LEDvalue to switch the 3 LED's status. So any LED status combination can be achieved. E.g. KeyboardLED("5","switch") will switch CapsLock and ScrollLock on.
PS: If ScrollLock is on when starting the script, it doens't blink in previous example. But this function was just a test to see I can use it somewhere, so it's not really finished.
[Edit: made script now more practical to use, avoiding situations like in above PS]
Last edited by Peter on Sat Mar 11, 2006 12:46 pm; edited 1 time in total |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Sat Mar 11, 2006 12:58 am Post subject: |
|
|
Here is an easy-to-use tool to determine what keyboard devices are present and active, and their device instance ids:
note: registry structure and layout have only been verified with Windows XP SP2
| Code: | loop, HKEY_LOCAL_MACHINE, SYSTEM\CurrentControlSet\Enum, 1, 1
{
if ( A_LoopRegName = "Class" )
{
RegRead, value
if ( InStr( value, "Keyboard" ) )
{
RegRead, value2, %A_LoopRegKey%, %A_LoopRegSubKey%\Control, ActiveService
if value2!=
{
StringTrimLeft, value, A_LoopRegSubKey, InStr( A_LoopRegSubKey, "\Enum\" )+5
RegRead, value3, %A_LoopRegKey%, %A_LoopRegSubKey%, DeviceDesc
text = %text%`n[%A_LoopRegSubKey%]`ndevice_instance_id = %value%`n%value2%`n%value3%`n
}
}
}
}
MsgBox, %text% |
Peter:
You will need to edit your function as follows:
replace:
| Code: | h_device := DllCall( "CreateFile"
, "str", device
, "uint", 0
, "uint", 0 |
with:
| Code: | h_device := DllCall( "CreateFile"
, "str", device
, "uint", 0
, "uint", 1 ; FILE_SHARE_READ |
It would be advisable to leave the following comment in place:
| Quote: | ; -- input bit pattern (KeyLED) --
; bit 0 = scroll lock
; bit 1 = num lock
; bit 2 = caps lock |
Otherwise, it looks good. Thanks. |
|
| Back to top |
|
 |
Peter
Joined: 30 Dec 2005 Posts: 279
|
Posted: Sat Mar 11, 2006 1:11 pm Post subject: |
|
|
@Shimanov: thanks for all your remarks on my original script. (I obviously didn't take over your edited script. )
| shimanov wrote: | | easy-to-use tool to determine what keyboard devices are present and active | I didn't put it in my script yet. I will check it out on some other PC (I remember that your other tool gave 3 results, see previous post). |
|
| Back to top |
|
 |
shimanov
Joined: 25 Sep 2005 Posts: 612
|
Posted: Sat Mar 11, 2006 3:21 pm Post subject: |
|
|
| Peter wrote: | | I remember that your other tool gave 3 results, see previous post. |
The earlier script returned all (active and otherwise) devices. The new script returns only active devices. |
|
| 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
|