CoordMode, ToolTip
hHookKeybd := DllCall("SetWindowsHookEx"
, Int, WH_KEYBOARD_LL := 13
, Ptr, RegisterCallback("LowLevelKeyboardProc", "Fast")
, Ptr, DllCall("GetModuleHandle", UInt, 0, Ptr)
, UInt, 0, Ptr)
OnExit( Func("Exit").Bind(hHookKeybd) )
Return
Esc::ExitApp
Exit(hHookKeybd) {
DllCall("UnhookWindowsHookEx", Ptr, hHookKeybd)
}
LowLevelKeyboardProc(nCode, wParam, lParam) {
static lpData, size := VarSetCapacity(lpData, 16, 0)
DllCall("RtlMoveMemory", Ptr, &lpData, Ptr, lParam, Ptr, size)
timer := Func("EventHandling").Bind(wParam, &lpData)
SetTimer, % timer, -10
Return DllCall("CallNextHookEx", Ptr, 0, Int, nCode, Ptr, wParam, Ptr, lParam)
}
EventHandling(wp, lp) {
static oMsg := {0x100: "WM_KEYDOWN", 0x101: "WM_KEYUP", 0x104: "WM_SYSKEYDOWN", 0x105: "WM_SYSKEYUP"}
, oMembers := ["vk", "sc", "flags", "time"]
, oFlagOffsets := {LLKHF_EXTENDED: 0, LLKHF_LOWER_IL_INJECTED: 1, LLKHF_INJECTED: 4, LLKHF_ALTDOWN: 5, LLKHF_UP: 7}
, oModifiersSC := { LCtrl: 0x1D , LShift: 0x2A , LAlt: 0x38
, RCtrl: 0x11D, RShift: 0x136, RAlt: 0x138 }
, oModifiersPressed := {}
msg := wp
for k, v in oMembers
%v% := NumGet(lp + (k - 1)*4, "UInt")
for k, v in oFlagOffsets
%k% := (flags >> v) & 1
sc |= LLKHF_EXTENDED << 8
for k, v in oModifiersSC {
if (sc = v && Modifier := true) {
if LLKHF_UP
oModifiersPressed.Delete(k)
else
oModifiersPressed[k] := true
}
}
if !(Modifier || LLKHF_UP) {
for k in oModifiersPressed
ModifiersString .= (A_Index = 1 ? "" : " + ") . k
if ModifiersString
ToolTip, % "Вы нажали " . ModifiersString . " + " . GetEngKeyName(sc)
}
}
GetEngKeyName(sc) {
static Cyr := "ёйцукенгшщзхъфывапролджэячсмитьбю,.""№;?:"
, Lat := "``qwertyuiop[]asdfghjkl;'zxcvbnm,.?/@#$&^"
KeyName := GetKeyName( "sc" . Format("{:X}", sc) )
threadId := DllCall("GetWindowThreadProcessId", Ptr, WinExist("A"), UInt, 0, Ptr)
landId := DllCall("GetKeyboardLayout", Ptr, threadId, Ptr) & 0xFFFF
if ( landId = 0x419 && (n := InStr(Cyr, KeyName)) )
KeyName := SubStr(Lat, n, 1)
Return RegExReplace(KeyName, "^(.)", "$U1")
}
Не думаю, что сильно прояснилось.