From a1cdf84419972ae18fec1896f59ab9be68be988b Mon Sep 17 00:00:00 2001 From: dennis Date: Tue, 24 Jun 2008 12:12:18 +0000 Subject: =?UTF-8?q?Aktivierter=20Mod4=20Lock=20wird=20jetzt=20=C3=BCber=20?= =?UTF-8?q?die=20Rollen-LED=20des=20Keybord=20angezeigt=20(analog=20zu=20C?= =?UTF-8?q?apsLock),=20dementsprechende=20neue=20Option=20im=20Skript:=20U?= =?UTF-8?q?seMod4Light?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.neo-layout.org@566 b9310e46-f624-0410-8ea1-cfbb3a30dc96 --- windows/autohotkey/neo20-all-in-one.ahk | 145 ++++++++++++++++++++++++++++++-- windows/autohotkey/neo20-all-in-one.exe | Bin 420718 -> 421724 bytes 2 files changed, 140 insertions(+), 5 deletions(-) (limited to 'windows') diff --git a/windows/autohotkey/neo20-all-in-one.ahk b/windows/autohotkey/neo20-all-in-one.ahk index 540a7bf..979cb94 100644 --- a/windows/autohotkey/neo20-all-in-one.ahk +++ b/windows/autohotkey/neo20-all-in-one.ahk @@ -14,7 +14,11 @@ Ideen: - Symbol ändern (Neo-Logo abwarten) - bei Ebene 4 rechte Hand (Numpad) z.B. Numpad5 statt 5 senden CHANGEHISTORY: - Aktuelle Revision (von Matthias Berg): + Aktuelle Revision (von Dennis Heidsiek): + - Aktivierter Mod4 Lock wird jetzt über die Rollen-LED des Keybord angazeigt + (analog zu CapsLock), die NUM-LED behält ihr bisheriges Verhalten + - Neue Option im Skript: UseMod4Light + Revision 561 (von Matthias Berg): - Ebene 4 Tab verhält sich jetzt wie das andere Tab dank "goto neo_tab" Revision 560 (von Dennis Heidsiek): - Neue Option im Skript: bildschirmTastaturEinbinden bindet die PNG-Bilder der @@ -110,6 +114,7 @@ ahkTreiberKombi := 0 ; Sollen Ebenen 1-4 ignoriert werden? (kann z.B. vom dll Tr einHandNeo := 0 ; Soll der Treiber im Einhandmodus betrieben werden? lernModus := 0 ; Soll der Lernmodus aktiviert werden? bildschirmTastaturEinbinden := 1 ; Sollen die Bilder für die Bildschirmtastatur in die EXE-Datei miteingebunden werden (Nachteil: grössere Dateigrösse, Vorteil: Referenz für Anfanger stets einfach verfügbar) +UseMod4Light := 1 ; Aktivierter Mod4 Lock wird über die Rollen-LED des Keybord angazeigt (analog zu CapsLock) Process, Priority,, High @@ -144,7 +149,7 @@ if ( FileExist("neo.ico") && FileExist("neo_disabled.ico") ) lernModus Konfiguration * nur relevant wenn * lernModus = 1 * - Strg+Komma schaltet um * + Strg+Komma schaltet um * ************************** */ ; 0 = aus, 1 = an @@ -336,11 +341,18 @@ IsMod4Locked := 0 { ; MsgBox Mod4-Feststellung aufgebehoben IsMod4Locked = 0 + if (UseMod4Light==1) { + KeyboardLED(1,"off") + } } else { -; MsgBox Mod4 festgestellt: Um Mod4 wieder zu lösen drücke beide Mod4 Tasten gleichzeitig +; MsgBox Mod4 festgestellt: Um Mod4 wieder zu lösen drücke beide Mod4 Tasten gleichzeitig IsMod4Locked = 1 + if (UseMod4Light==1) { + KeyboardLED(1,"on") + } + } return *SC138:: @@ -363,7 +375,6 @@ SC138 & *<:: IsMod4Locked = 1 } return - */ ; Mod3-Lock durch Mod3+Mod3 @@ -389,8 +400,9 @@ IsMod3Locked := 0 } return -;Capslock::MsgBox hallo + *Capslock:: return +;Capslock::MsgBox hallo /* Capslock & *#:: if (IsMod3Locked) @@ -4512,6 +4524,129 @@ EncodeInteger(ref, val) + +/* + ------------------------------------------------------ + Methode zur Steuerung der Keyboard-LEDs + (NumLock/CapsLock/ScrollLock-Lichter) + + Benutzungshinweise: + KeyboardLED(LEDvalue,"Cmd"), wobei + Cmd = on/off/switch, + LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 + bzw. eine beliebige Summe dieser Werte: + AlleAus=0, CapsLock+NumLock=6, etc. + + Der folgende Code wurde übernommen von: + http://www.autohotkey.com/forum/viewtopic.php?t=10532 + + Um eventuelle Wechselwirkungen mit dem bestehenden + Code (insb. der Unicode-Konvertierung) auszuschießen, + sind auch alle (Hilfsmethoden) mit dem Postfix LED + versehen worden. + ------------------------------------------------------ +*/ + +KeyboardLED(LEDvalue, Cmd) ; LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 ; Cmd = on/off/switch +{ + Static h_device + If ! h_device ; initialise + { + device =\Device\KeyBoardClass0 + SetUnicodeStrLED(fn,device) + h_device:=NtCreateFileLED(fn,0+0x00000100+0x00000080+0x00100000,1,1,0x00000040+0x00000020,0) + } + + 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")) + } + ; EncodeIntegerLED( KeyLED, 1, &input, 2 ) ;input bit pattern (KeyLED): bit 0 = scrolllock ;bit 1 = numlock ;bit 2 = capslock + 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 ) +} + +CTL_CODE( p_device_type, p_function, p_method, p_access ) +{ + Return, ( p_device_type << 16 ) | ( p_access << 14 ) | ( p_function << 2 ) | p_method +} + + +NtCreateFileLED(ByRef wfilename,desiredaccess,sharemode,createdist,flags,fattribs) +{ + VarSetCapacity(fh,4,0) + VarSetCapacity(objattrib,24,0) + VarSetCapacity(io,8,0) + VarSetCapacity(pus,8) + uslen:=DllCall("lstrlenW","str",wfilename)*2 + InsertIntegerLED(uslen,pus,0,2) + InsertIntegerLED(uslen,pus,2,2) + InsertIntegerLED(&wfilename,pus,4) + InsertIntegerLED(24,objattrib,0) + InsertIntegerLED(&pus,objattrib,8) + status:=DllCall("ntdll\ZwCreateFile","str",fh,"UInt",desiredaccess,"str",objattrib,"str",io,"UInt",0,"UInt",fattribs + ,"UInt",sharemode,"UInt",createdist,"UInt",flags,"UInt",0,"UInt",0, "UInt") + return % ExtractIntegerLED(fh) +} + + +SetUnicodeStrLED(ByRef out, str_) +{ + VarSetCapacity(st1, 8, 0) + InsertIntegerLED(0x530025, st1) + VarSetCapacity(out, (StrLen(str_)+1)*2, 0) + DllCall("wsprintfW", "str", out, "str", st1, "str", str_, "Cdecl UInt") +} + + +ExtractIntegerLED(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4) +; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset. +; The caller should pass true for pSigned to interpret the result as signed vs. unsigned. +; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int). +; pSource must be ByRef to avoid corruption during the formal-to-actual copying process +; (since pSource might contain valid data beyond its first binary zero). +{ + Loop %pSize% ; Build the integer by adding up its bytes. + result += *(&pSource + pOffset + A_Index-1) << 8*(A_Index-1) + if (!pIsSigned OR pSize > 4 OR result < 0x80000000) + return result ; Signed vs. unsigned doesn't matter in these cases. + ; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart: + return -(0xFFFFFFFF - result + 1) +} + + +InsertIntegerLED(pInteger, ByRef pDest, pOffset = 0, pSize = 4) +; The caller must ensure that pDest has sufficient capacity. To preserve any existing contents in pDest, +; only pSize number of bytes starting at pOffset are altered in it. +{ + Loop %pSize% ; Copy each byte in the integer into the structure as raw binary data. + DllCall("RtlFillMemory", "UInt", &pDest + pOffset + A_Index-1, "UInt", 1, "UChar", pInteger >> 8*(A_Index-1) & 0xFF) +} + + + /* ------------------------------------------------------ BildschirmTastatur diff --git a/windows/autohotkey/neo20-all-in-one.exe b/windows/autohotkey/neo20-all-in-one.exe index e83af2e..2982add 100644 Binary files a/windows/autohotkey/neo20-all-in-one.exe and b/windows/autohotkey/neo20-all-in-one.exe differ -- cgit v1.2.3