From 20f0f35ab41df06e40b6e159c4e58865a2b0b97f Mon Sep 17 00:00:00 2001 From: martin_r Date: Wed, 27 Aug 2008 17:13:08 +0000 Subject: Überflüssigen Code entfernt, Code gestrafft MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.neo-layout.org@812 b9310e46-f624-0410-8ea1-cfbb3a30dc96 --- windows/autohotkey/Source/Methods-Lights.ahk | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'windows/autohotkey/Source/Methods-Lights.ahk') diff --git a/windows/autohotkey/Source/Methods-Lights.ahk b/windows/autohotkey/Source/Methods-Lights.ahk index d74a4e3..62c2687 100644 --- a/windows/autohotkey/Source/Methods-Lights.ahk +++ b/windows/autohotkey/Source/Methods-Lights.ahk @@ -20,10 +20,9 @@ ------------------------------------------------------ */ -KeyboardLED(LEDvalue, Cmd){ ; LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 ; Cmd = on/off/switch +KeyboardLED(LEDvalue, Cmd) { ; LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 ; Cmd = on/off/switch Static h_device - If ! h_device ; initialise - { + If !(h_device) { ; initialise device=\Device\KeyBoardClass0 SetUnicodeStrLED(fn,device) h_device:=NtCreateFileLED(fn,0+0x00000100+0x00000080+0x00100000,1,1,0x00000040+0x00000020,0) @@ -35,15 +34,15 @@ KeyboardLED(LEDvalue, Cmd){ ; LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 ; Cm 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) - { + 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= + 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 @@ -58,8 +57,8 @@ KeyboardLED(LEDvalue, Cmd){ ; LEDvalue: ScrollLock=1, NumLock=2, CapsLock=4 ; Cm , "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 +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){ @@ -78,14 +77,14 @@ NtCreateFileLED(ByRef wfilename,desiredaccess,sharemode,createdist,flags,fattrib return ExtractIntegerLED(fh) } -SetUnicodeStrLED(ByRef out, str_){ +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){ +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). @@ -99,7 +98,7 @@ ExtractIntegerLED(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4){ return -(0xFFFFFFFF - result + 1) } -InsertIntegerLED(pInteger, ByRef pDest, pOffset = 0, pSize = 4){ +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. -- cgit v1.2.3