From d7c07f2aad09fd84dc5eb43ffcfa4f5d19bf0e5e Mon Sep 17 00:00:00 2001 From: dennis Date: Wed, 2 Jul 2008 14:06:46 +0000 Subject: Der Versuch, das viel zu lange gewordenene AHK-Skript in logische Eizelteile aufzuteilen. git-svn-id: https://svn.neo-layout.org@591 b9310e46-f624-0410-8ea1-cfbb3a30dc96 --- windows/autohotkey/neo20-all-in-one.ahk | 387 +++++++++++++++++--------------- 1 file changed, 208 insertions(+), 179 deletions(-) (limited to 'windows/autohotkey/neo20-all-in-one.ahk') diff --git a/windows/autohotkey/neo20-all-in-one.ahk b/windows/autohotkey/neo20-all-in-one.ahk index 1532d71..72b4efc 100644 --- a/windows/autohotkey/neo20-all-in-one.ahk +++ b/windows/autohotkey/neo20-all-in-one.ahk @@ -6,8 +6,7 @@ Dies ist inzwischen eine automatisch generierte Datei! Sie wird regelmäßig übrerschrieben und sollte -deshalb nicht mehr bearbeitet werden! - +deshalb nicht mehr direkt bearbeitet werden! Statdessen sollten die Dateien/Module im @@ -104,6 +103,8 @@ DU BIST GEWARNT WORDEN! - bei Ebene 4 rechte Hand (Numpad) z.B. Numpad5 statt 5 senden CHANGEHISTORY: Aktuelle Revision (von Matthias Berg): + - Bildschirmtastatur jetzt mit Mod4+F* statt Strg+F* + Revision 583 (von Matthias Berg): - Hotkeys für einHandNeo und lernModus durch entsprechende ScanCodes ersetzt Revision 568 (von Matthias Berg): - Sonderzeichen, Umlaute, z und y durch ScanCodes ersetzt @@ -200,6 +201,7 @@ DU BIST GEWARNT WORDEN! */ + /****************** Globale Schalter * ******************* @@ -284,7 +286,7 @@ lernModus_neo_Entf = 1 ; msgbox ist trotzdem linksbündig SetTitleMatchMode 2 -SendMode Input +SendMode Input name = Neo 2.0 enable = Aktiviere %name% @@ -319,6 +321,8 @@ if inputlocale <> 00000407 exitapp } + + ; Menü des Systray-Icons ; ---------------------- @@ -394,6 +398,7 @@ gespiegelt_j = neo_ + /* ------------------------------------------------------ Modifier @@ -407,7 +412,7 @@ gespiegelt_j = neo_ *#::return ; Nichts machen beim # release event (weil es Mod3 ist) ; # = SC02B ;RShift wenn vorher LShift gedrückt wurde -LShift & ~RShift:: +LShift & ~RShift:: if GetKeyState("CapsLock","T") { setcapslockstate, off @@ -519,6 +524,8 @@ return */ + + /* ------------------------------------------------------ QWERTZ->Neo umwandlung @@ -598,7 +605,7 @@ return *w:: if ( not(ahkTreiberKombi) ) { - goto neo_v + goto neo_v } else { @@ -607,7 +614,7 @@ return *e:: if ( not(ahkTreiberKombi) ) { - goto neo_l + goto neo_l } else { @@ -996,8 +1003,12 @@ return *NumpadIns::goto neo_NumpadIns *NumpadDel::goto neo_NumpadDel - + + /* +Die eigentliche NEO-Belegung und der Hauptteil des AHK-Treibers. + + Ablauf bei toten Tasten: 1. Ebene Aktualisieren 2. Abhängig von der Variablen "Ebene" Zeichen ausgeben und die Variable "PriorDeadKey" setzen @@ -1164,7 +1175,7 @@ neo_2: CompKey := "" } else if Ebene = 3 - { + { SendUnicodeChar(0x00B2) ; 2 Hochgestellte CompKey := "" } @@ -1290,7 +1301,7 @@ neo_4: CompKey := "4" else CompKey := "" - } + } else if Ebene = 2 { send » @@ -1364,7 +1375,7 @@ neo_5: CompKey := "5" else CompKey := "" - } + } else if Ebene = 2 { send « @@ -1431,7 +1442,7 @@ neo_6: CompKey := "6" else CompKey := "" - } + } else if Ebene = 2 { send € @@ -1494,7 +1505,7 @@ neo_7: CompKey := "7" else CompKey := "" - } + } else if Ebene = 2 { send $ @@ -1568,7 +1579,7 @@ neo_8: CompKey := "8" else CompKey := "" - } + } else if Ebene = 2 { send „ @@ -1631,7 +1642,7 @@ neo_9: CompKey := "9" else CompKey := "" - } + } else if Ebene = 2 { send “ @@ -1694,7 +1705,7 @@ neo_0: CompKey := "0" else CompKey := "" - } + } else if Ebene = 2 { send ” @@ -2345,7 +2356,7 @@ neo_u: send \ else if Ebene = 4 Send {blind}{Home} - else if Ebene = 5 + else if Ebene = 5 { } ; leer else if Ebene = 6 SendUnicodeChar(0x222E) ; contour integral @@ -2422,7 +2433,7 @@ neo_i: Sendinput {Blind}{Left} CompKey := "" } - else if Ebene = 5 + else if Ebene = 5 { SendUnicodeChar(0x03B9) ; iota CompKey := "" @@ -2622,7 +2633,7 @@ neo_o: else if (PriorDeadKey = "a4") ; ogonek BSSendUnicodeChar(0x01EB) else if (PriorDeadKey = "c2") ; caron - BSSendUnicodeChar(0x01D2) + BSSendUnicodeChar(0x01D2) else sendinput {blind}o if (PriorDeadKey = "comp") ; compose @@ -3006,9 +3017,9 @@ neo_y: else if Ebene = 3 send @ else if Ebene = 4 - Send . + Send . else if Ebene = 5 - SendUnicodeChar(0x03C5) ; upsilon + SendUnicodeChar(0x03C5) ; upsilon else if Ebene = 6 SendUnicodeChar(0x2207) ; nabla PriorDeadKey := "" CompKey := "" @@ -3883,6 +3894,7 @@ neo_NumpadPgUp: } else if ( (Ebene = 4) or (Ebene = 5) ) { + SendUnicodeChar(0x226B) ; gg CompKey := "" } @@ -4145,7 +4157,7 @@ return */ *space:: if (einHandNeo) - spacepressed := 1 + spacepressed := 1 else goto neo_SpaceUp return @@ -4156,7 +4168,7 @@ return if (keypressed) { keypressed := 0 - spacepressed := 0 + spacepressed := 0 } else { @@ -4196,8 +4208,8 @@ neo_SpaceUp: else if Ebene = 6 SendUnicodeChar(0x202F) ; schmales Leerzeichen PriorDeadKey := "" CompKey := "" - spacepressed := 0 - keypressed := 0 + spacepressed := 0 + keypressed := 0 return /* @@ -4285,7 +4297,7 @@ nach einem DeadKey dr neo_tab: if ( GetKeyState("SC038","P") ) { - Send,{Blind}{AltDown}{tab} + Send,{Blind}{AltDown}{tab} /* if (isShiftPressed()) @@ -4295,7 +4307,7 @@ neo_tab: else { ; msgbox alt+tab - Send,{AltDown}{tab} + Send,{AltDown}{tab} ; SC038 & Tab::AltTab ; http://de.autohotkey.com/docs/Hotkeys.htm#AltTabDetail } */ @@ -4317,7 +4329,7 @@ return return *SC038 down:: ; LAlt, damit AltTab funktioniert - Send,{Blind}{AltDown} + Send,{Blind}{AltDown} PriorDeadKey := "" CompKey := "" return @@ -4386,6 +4398,131 @@ return return + + +/* + ------------------------------------------------------ + Methode KeyboardLED zur Steuerung der Keyboard-LEDs + (NumLock/CapsLock/ScrollLock-Lichter) + + Benutzungshinweise: Man benutze + 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_LED( 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_LED( 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) +} + + + + /* ------------------------------------------------------ Funktionen @@ -4417,8 +4554,8 @@ EbeneAktualisieren() { if ( IsShiftPressed() ) { ; Umschalt - if ( IsMod3Pressed() ) - { ; Umschalt UND Mod3 + if ( IsMod3Pressed() ) + { ; Umschalt UND Mod3 if ( IsMod4Pressed() ) { ; Umschald UND Mod3 UND Mod4 ; Ebene 8 impliziert Ebene 6 @@ -4426,11 +4563,11 @@ EbeneAktualisieren() } else { ; Umschald UND Mod3 NICHT Mod4 - Ebene = 5 + Ebene = 5 } } - else - { ; Umschalt NICHT Mod3 + else + { ; Umschalt NICHT Mod3 if ( IsMod4Pressed() ) { ; Umschald UND Mod4 NICHT Mod3 ; Ebene 7 impliziert Ebene 4 @@ -4438,25 +4575,25 @@ EbeneAktualisieren() } else { ; Umschald NICHT Mod3 NICHT Mod4 - Ebene = 2 + Ebene = 2 } } } else { ; NICHT Umschalt - if ( IsMod3Pressed() ) - { ; Mod3 NICHT Umschalt + if ( IsMod3Pressed() ) + { ; Mod3 NICHT Umschalt if ( IsMod4Pressed() ) { ; Mod3 UND Mod4 NICHT Umschalt Ebene = 6 } else { ; Mod3 NICHT Mod4 NICHT Umschalt - Ebene = 3 + Ebene = 3 } } - else - { ; NICHT Umschalt NICHT Mod3 + else + { ; NICHT Umschalt NICHT Mod3 if ( IsMod4Pressed() ) { ; Mod4 NICHT Umschalt NICHT Mod3 Ebene = 4 @@ -4465,7 +4602,7 @@ EbeneAktualisieren() { ; NICHT Umschalt NICHT Mod3 NICHT Mod4 Ebene = 1 } - } + } } } } @@ -4485,7 +4622,7 @@ IsMod3Pressed() return (not ( GetKeyState("CapsLock","P") or GetKeyState("#","P") )) ; # = SC02B } else { - return ( GetKeyState("CapsLock","P") or GetKeyState("#","P") ) ; # = SC02B + return ( GetKeyState("CapsLock","P") or GetKeyState("#","P") ) ; # = SC02B } } @@ -4573,7 +4710,7 @@ BSSendUnicodeChar(charCode) CompUnicodeChar(charCode) { send {bs} - SendUnicodeChar(charCode) + SendUnicodeChar(charCode) } Comp3UnicodeChar(charCode) @@ -4592,127 +4729,6 @@ 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_LED( 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_LED( 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) -} - - /* ------------------------------------------------------ @@ -4722,55 +4738,62 @@ InsertIntegerLED(pInteger, ByRef pDest, pOffset = 0, pSize = 4) guiErstellt = 0 alwaysOnTop = 1 aktuellesBild = ebene1.png -^~F1:: +SC056 & *F1:: +SC138 & *F1:: { if (zeigeBildschirmTastatur) goto Switch1 return } -^~F2:: +SC056 & *F2:: +SC138 & *F2:: { if (zeigeBildschirmTastatur) goto Switch2 return } -^~F3:: +SC056 & *F3:: +SC138 & *F3:: { if (zeigeBildschirmTastatur) goto Switch3 return } -^~F4:: +SC056 & *F4:: +SC138 & *F4:: { if (zeigeBildschirmTastatur) goto Switch4 return } -^~F5:: +SC056 & *F5:: +SC138 & *F5:: { if (zeigeBildschirmTastatur) goto Switch5 return } -^~F6:: +SC056 & *F6:: +SC138 & *F6:: { if (zeigeBildschirmTastatur) goto Switch6 return } -^~F7:: +SC056 & *F7:: +SC138 & *F7:: { if (zeigeBildschirmTastatur) goto Show return } -^~F8:: +SC056 & *F8:: +SC138 & *F8:: { if (zeigeBildschirmTastatur) - goto ToggleAlwaysOnTop + goto ToggleAlwaysOnTop return } - Switch1: if (guiErstellt) { @@ -4886,12 +4909,12 @@ Show: } else { - if (Image = "") + if (Image = "") { Image = ebene1.png } yPosition := A_ScreenHeight -270 - Gui, Color, FFFFFF + Gui, Color, FFFFFF Gui, Add, Button, xm+5 gSwitch1, F1 Gui, Add, Text, x+5, kleine Buchstaben Gui, Add, Button, xm+5 gSwitch2, F2 @@ -4967,8 +4990,8 @@ togglesuspend: if A_IsSuspended { menu, tray, rename, %enable%, %disable% - menu, tray, tip, %name% - if (iconBenutzen) + menu, tray, tip, %name% + if (iconBenutzen) menu, tray, icon, neo.ico,,1 suspend , off ; Schaltet Suspend aus -> NEO } @@ -4976,8 +4999,8 @@ togglesuspend: { menu, tray, rename, %disable%, %enable% menu, tray, tip, %name% : Deaktiviert - if (iconBenutzen) - menu, tray, icon, neo_disabled.ico,,1 + if (iconBenutzen) + menu, tray, icon, neo_disabled.ico,,1 suspend , on ; Schaltet Suspend ein -> QWERTZ } @@ -5033,4 +5056,10 @@ return exitprogram: exitapp -return \ No newline at end of file +return + + + + + + \ No newline at end of file -- cgit v1.2.3