Code: Select all
WheelUp::ToolTip % GetKeyState("WheelUp", "P")
#InputLevel, 100
3::Send {WheelUp}
I understand that Wheel does not have an Up event, but you can make a definition of a physical or emulated push, since this can now be done with the rest of the keys.
For example, button 2.
Code: Select all
2::ToolTip % GetKeyState("2", "P")
#InputLevel, 100
3::Send {2}
In any case, it is not difficult to do for hotkeys mousehook.
Code: Select all
#SingleInstance Force
#NoEnv
#Persistent
CoordMode, ToolTip
MouseHook.Set()
1::Send {WheelUp}
2::Send {WheelDown}
esc::ExitApp
class MouseHook
{
Set() {
if !this.hook {
this.hook := this.SetMouseHook()
OnExit( this.OnExit := ObjBindMethod(this, "Del") )
}
}
Del() {
if this.hook {
this.SetMouseHook(this.hook)
this.hook := ""
OnExit(this.OnExit, 0)
}
}
SetMouseHook(hHook := "") {
if hHook
DllCall("UnhookWindowsHookEx", Ptr, hHook)
else
Return hHook := DllCall("SetWindowsHookEx", Int, WH_MOUSE_LL := 14
, Int, RegisterCallback("LowLevelMouseProc", "Fast")
, Ptr, DllCall("GetModuleHandle", UInt, 0, Ptr)
, UInt, 0, Ptr)
}
}
LowLevelMouseProc(nCode, wParam, lParam) {
static oMem := [], lpData, size := VarSetCapacity(lpData, 16 + A_PtrSize*2, 0)
If (wParam != 0x20A) ; WM_MOUSEWHEEL
Return DllCall("CallNextHookEx", Ptr, 0, Int, nCode, Ptr, wParam, Ptr, lParam)
DllCall("RtlMoveMemory", Ptr, &lpData, Ptr, lParam, Ptr, size)
oMem.Push([wParam, &lpData])
timer := Func("EventHandling").Bind(oMem) ; во избежание фризов мыши обработка событий должна
SetTimer, % timer, -10 ; происходить обязательно по таймеру, а не в теле этой функции
Return DllCall("CallNextHookEx", Ptr, 0, Int, nCode, Ptr, wParam, Ptr, lParam)
}
EventHandling(oMem) {
while event := oMem.RemoveAt(1) {
ext := NumGet(event[2] + 10, "Short")
flags := NumGet(event[2] + 12, "UInt")
INJECTED := flags & 1
ToolTip % (ext = 120 ? "WheelUp" : "WheelDown") "`n" (INJECTED ? "Emulated" : "Physical")
}
}