primer commit
This commit is contained in:
commit
4f0cd24497
1 changed files with 523 additions and 0 deletions
523
piusareLED.ahk
Normal file
523
piusareLED.ahk
Normal file
|
|
@ -0,0 +1,523 @@
|
||||||
|
#SingleInstance
|
||||||
|
|
||||||
|
scrLkLed := 0
|
||||||
|
numLkLed := 0
|
||||||
|
capLkLed := 0
|
||||||
|
|
||||||
|
KeyboardLED(LEDvalue, Cmd, Kbd=0)
|
||||||
|
{
|
||||||
|
global scrLkLed, numLkLed, capLkLed
|
||||||
|
|
||||||
|
SetUnicodeStr(fn,"\Device\KeyBoardClass" Kbd)
|
||||||
|
h_device:=NtCreateFile(fn,0+0x00000100+0x00000080+0x00100000,1,1,0x00000040+0x00000020,0)
|
||||||
|
|
||||||
|
If Cmd= switch ;switches every LED according to LEDvalue
|
||||||
|
{
|
||||||
|
scrLkToggle:=(1<<0)
|
||||||
|
numlkToggle:=(1<<1)
|
||||||
|
capLkToggle:=(1<<2)
|
||||||
|
newState:=0
|
||||||
|
;curState:= (GetKeyState("ScrollLock", "T")) + 2*(GetKeyState("NumLock", "T")) + 4*(GetKeyState("CapsLock", "T"))
|
||||||
|
if (LEDvalue & scrLkToggle) {
|
||||||
|
newState += !(scrLkLed)
|
||||||
|
scrLkLed := !(scrLkLed)
|
||||||
|
;MsgBox % newState . " scr " . scrLkLed
|
||||||
|
}
|
||||||
|
else newState += (scrLkLed)
|
||||||
|
if (LEDvalue & numLkToggle)
|
||||||
|
newState += 2*(!(GetKeyState("NumLock", "T")))
|
||||||
|
else newState += 2*((GetKeyState("NumLock", "T")))
|
||||||
|
if (LEDvalue & capLkToggle)
|
||||||
|
newState += 4*(!(GetKeyState("CapsLock", "T")))
|
||||||
|
else newState += 4*((GetKeyState("CapsLock", "T")))
|
||||||
|
;MsgBox % newState
|
||||||
|
KeyLED:=newState
|
||||||
|
}
|
||||||
|
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"))
|
||||||
|
}
|
||||||
|
|
||||||
|
success := DllCall( "DeviceIoControl"
|
||||||
|
, "ptr", h_device
|
||||||
|
, "uint", CTL_CODE( 0x0000000b ; FILE_DEVICE_KEYBOARD
|
||||||
|
, 2
|
||||||
|
, 0 ; METHOD_BUFFERED
|
||||||
|
, 0 ) ; FILE_ANY_ACCESS
|
||||||
|
, "int*", KeyLED << 16
|
||||||
|
, "uint", 4
|
||||||
|
, "ptr", 0
|
||||||
|
, "uint", 0
|
||||||
|
, "ptr*", output_actual
|
||||||
|
, "ptr", 0 )
|
||||||
|
|
||||||
|
NtCloseFile(h_device)
|
||||||
|
return 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
|
||||||
|
}
|
||||||
|
|
||||||
|
NtCreateFile(ByRef wfilename,desiredaccess,sharemode,createdist,flags,fattribs)
|
||||||
|
{
|
||||||
|
VarSetCapacity(objattrib,6*A_PtrSize,0)
|
||||||
|
VarSetCapacity(io,2*A_PtrSize,0)
|
||||||
|
VarSetCapacity(pus,2*A_PtrSize)
|
||||||
|
DllCall("ntdll\RtlInitUnicodeString","ptr",&pus,"ptr",&wfilename)
|
||||||
|
NumPut(6*A_PtrSize,objattrib,0)
|
||||||
|
NumPut(&pus,objattrib,2*A_PtrSize)
|
||||||
|
status:=DllCall("ntdll\ZwCreateFile","ptr*",fh,"UInt",desiredaccess,"ptr",&objattrib
|
||||||
|
,"ptr",&io,"ptr",0,"UInt",fattribs,"UInt",sharemode,"UInt",createdist
|
||||||
|
,"UInt",flags,"ptr",0,"UInt",0, "UInt")
|
||||||
|
return % fh
|
||||||
|
}
|
||||||
|
|
||||||
|
NtCloseFile(handle)
|
||||||
|
{
|
||||||
|
return DllCall("ntdll\ZwClose","ptr",handle)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SetUnicodeStr(ByRef out, str_)
|
||||||
|
{
|
||||||
|
VarSetCapacity(out,2*StrPut(str_,"utf-16"))
|
||||||
|
StrPut(str_,&out,"utf-16")
|
||||||
|
}
|
||||||
|
|
||||||
|
caps_lock_state := false
|
||||||
|
test_fn := Func("KeyboardLED").bind(1, "switch", 0)
|
||||||
|
|
||||||
|
*CapsLock::
|
||||||
|
Global test_fn
|
||||||
|
caps_lock_state := !(caps_lock_state)
|
||||||
|
if (caps_lock_state) {
|
||||||
|
SetTimer, % test_fn, 200
|
||||||
|
KeyboardLED(1,"on",0)
|
||||||
|
} else {
|
||||||
|
SetTimer, % test_fn, Off
|
||||||
|
KeyboardLED(1,"off",0)
|
||||||
|
}
|
||||||
|
("CapsLock")
|
||||||
|
return
|
||||||
|
|
||||||
|
/*r::
|
||||||
|
MsgBox % "SI" . caps_lock_state . "e"
|
||||||
|
return
|
||||||
|
|
||||||
|
GUIA:
|
||||||
|
|
||||||
|
H,J,K,L-LEFT, DOWN, UP, RIGHT
|
||||||
|
P,O-PGUP, PGDN
|
||||||
|
I,U-ctrl+X, ctrl+C
|
||||||
|
Ñ-ctrl+V
|
||||||
|
M-F2
|
||||||
|
,-F8
|
||||||
|
N-ctrl+Z
|
||||||
|
Y-ctrl+Y
|
||||||
|
E-S
|
||||||
|
D-ESC
|
||||||
|
C-F && H WHEN CTRL+SHIFT
|
||||||
|
|
||||||
|
F-CTRL
|
||||||
|
S-SHIFT
|
||||||
|
|
||||||
|
8::KeyboardLED(1,"switch",0)
|
||||||
|
|
||||||
|
7::
|
||||||
|
MsgBox % "var " . scrLkLed
|
||||||
|
return
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
LShift & RShift::CapsLock
|
||||||
|
RShift & LShift::CapsLock
|
||||||
|
;*CapsLock::return
|
||||||
|
|
||||||
|
#if caps_lock_state
|
||||||
|
|
||||||
|
f::return
|
||||||
|
X::return
|
||||||
|
s::return
|
||||||
|
a::return
|
||||||
|
|
||||||
|
h::
|
||||||
|
ctrlState := GetKeyState("F", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
altState := GetKeyState("a","P")
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Down}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Down}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Down}
|
||||||
|
|
||||||
|
SendInput {Left}
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Up}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Up}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Up}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
j::
|
||||||
|
ctrlState := GetKeyState("F", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
altState := GetKeyState("a","P")
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Down}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Down}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Down}
|
||||||
|
|
||||||
|
SendInput {Down}
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Up}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Up}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Up}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
l::
|
||||||
|
ctrlState := GetKeyState("F", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
altState := GetKeyState("a","P")
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Down}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Down}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Down}
|
||||||
|
|
||||||
|
SendInput {Right}
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Up}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Up}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Up}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
k::
|
||||||
|
ctrlState := GetKeyState("F", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
altState := GetKeyState("a","P")
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Down}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Down}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Down}
|
||||||
|
|
||||||
|
SendInput {Up}
|
||||||
|
|
||||||
|
if ctrlState = 1
|
||||||
|
SendInput {Ctrl Up}
|
||||||
|
if shiftState = 1
|
||||||
|
SendInput {Shift Up}
|
||||||
|
if altState = 1
|
||||||
|
SendInput {Alt Up}
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
m::
|
||||||
|
("m")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {F2}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{F2}") : ("^{F2}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
SendInput ^+{F2}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
p::
|
||||||
|
("p")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {PgDn}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{PgDn}") : ("^{PgDn}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
SendInput ^+{PgDn}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
o::
|
||||||
|
("o")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {PgUp}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{PgUp}") : ("^{PgUp}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
SendInput ^+{PgDn}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
sc027::
|
||||||
|
("sc027")
|
||||||
|
SendInput ^{v}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
i::
|
||||||
|
("i")
|
||||||
|
SendInput ^{x}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
u::
|
||||||
|
("u")
|
||||||
|
SendInput ^{c}
|
||||||
|
return
|
||||||
|
|
||||||
|
N::
|
||||||
|
("N")
|
||||||
|
SendInput ^{z}
|
||||||
|
return
|
||||||
|
|
||||||
|
Y::
|
||||||
|
("Y")
|
||||||
|
SendInput ^{y}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
sc033::
|
||||||
|
("sc033")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {F8}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{F8}") : ("^{F8}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
SendInput ^+{F8}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
C::
|
||||||
|
("C")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput ^{f}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("^{F}") : ("^{H}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
;SendInput % ("^+{keyboardActions[""c""]}")
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
E::
|
||||||
|
("E")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
SendInput, % ((shiftState == 1) ? ("^{S}") : ("^{s}"))
|
||||||
|
return
|
||||||
|
|
||||||
|
D::
|
||||||
|
("D")
|
||||||
|
SendInput {Esc}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
sc01A::
|
||||||
|
("sc01A")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {Del}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{Del}") : ("^{Del}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
;SendInput % ("^+{keyboardActions[""c""]}")
|
||||||
|
SendInput ^+{Del}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
sc01B::
|
||||||
|
("sc01B")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {Home}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{Home}") : ("^{Home}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
;SendInput % ("^+{keyboardActions[""c""]}")
|
||||||
|
SendInput ^+{Home}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
sc02B::
|
||||||
|
("sc02B")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {End}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{End}") : ("^{End}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
;SendInput % ("^+{keyboardActions[""c""]}")
|
||||||
|
SendInput ^+{End}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
sc028::
|
||||||
|
("sc028")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {Ins}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{Ins}") : ("^{Ins}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
;SendInput % ("^+{keyboardActions[""c""]}")
|
||||||
|
SendInput ^+{Ins}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Backspace::
|
||||||
|
("Backspace")
|
||||||
|
loop {
|
||||||
|
ctrlState := GetKeyState("f", "P")
|
||||||
|
shiftState := GetKeyState("s", "P")
|
||||||
|
switch (shiftState + ctrlState) {
|
||||||
|
case 0:
|
||||||
|
SendInput {Backspace}
|
||||||
|
return
|
||||||
|
case 1:
|
||||||
|
SendInput, % ((shiftState == 1) ? ("+{Backspace}") : ("^{Backspace}"))
|
||||||
|
return
|
||||||
|
case 2:
|
||||||
|
;SendInput % ("^+{keyboardActions[""c""]}")
|
||||||
|
SendInput ^+{Backspace}
|
||||||
|
return
|
||||||
|
default:
|
||||||
|
MsgBox % "menudo gilipolls"
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
#if
|
||||||
Loading…
Add table
Add a link
Reference in a new issue