Windows で何かを押しながらマウス移動でホイールをシミュレートするやつ2019版。その前に普通のホイールを加速するやつも付いてるけど、もちろんこっちは消してもいい。
CoordMode, Mouse, Screen
; あとで使う透明マウスポインタ
VarSetCapacity(AFF, 32 * 4, 0xFF)
VarSetCapacity(X00, 32 * 4, 0x00)
; cf. https://www6.atwiki.jp/eamat/pages/32.html
WheelUp::
WheelDown::
MouseGetPos, x, y, hwnd, ctrl, 1
; UWP?
If (ctrl == "")
WinGetClass, ctrl, ahk_id %hwnd%
If (ctrl ~= "^Windows\.UI\.Core\.CoreWindow")
{
; 適当に加速 (間隔700ms未満から加速し、400ms未満はもっと加速)
v := 1
If ((A_PriorHotkey == A_ThisHotkey)
and (A_TimeSincePriorHotkey < 700))
v += Floor((700 - A_TimeSincePriorHotkey) / 300) ** 3
SendInput, {Blind}{%A_ThisHotkey% %v%}
Return
}
v := (A_ThisHotkey == "WheelUp") ? 1 : -1
If ((A_PriorHotkey == A_ThisHotkey)
and (A_TimeSincePriorHotkey < 700))
v *= 1 + ((700 - A_TimeSincePriorHotkey) / 300) ** 3
; 適当に進む (120は、マウスの設定で1行にしているとき用って感じ)
PostMessage, 0x20A, Floor(120 * v) << 16
, (y << 16) | x
, %ctrl%, ahk_id %hwnd%
Return
; 中央ボタンを押しながらマウス移動でホイール動作のふり
*MButton::
MouseGetPos, sx, sy, hwnd, ctrl, 1
; UWP?
If (ctrl == "")
WinGetClass, ctrl, ahk_id %hwnd%
uwp := (ctrl ~= "^Windows\.UI\.Core\.CoreWindow")
; カーソル隠しとこう
bc := DllCall("CreateCursor", "UInt", 0, "Int", 0, "Int", 0, "Int", 32, "Int", 32, "UInt", &AFF, "UInt", &X00)
DllCall("SetSystemCursor", "UInt", bc, "Int", 32512) ; ノーマル
bc := DllCall("CreateCursor", "UInt", 0, "Int", 0, "Int", 0, "Int", 32, "Int", 32, "UInt", &AFF, "UInt", &X00)
DllCall("SetSystemCursor", "UInt", bc, "Int", 32513) ; 文字Iビーム
moved := false
While GetKeyState("MButton", "P")
{
MouseGetPos, x, y
If ((delta := sy - y) = 0)
Continue
Else
moved := true
If (!uwp)
{
PostMessage, 0x20A, ((delta*Abs(delta)) << 16) | mods()
, (sy << 16) | sx
, %ctrl% , ahk_id %hwnd%
}
Else
{
wud := (delta > 0) ? "WheelUp" : "WheelDown"
SendInput, {Blind}{%wud%}
}
; マウスカーソルが動いてしまっているので、元に戻す
MouseMove, sx, sy, 0
Continue
}
; カーソル表示
DllCall("SystemParametersInfo", "UInt", 0x57, "UInt", 0, "UInt", 0, "UInt", 0)
; ここでモディファイアが効いてるかどうかは知らん
If (!moved)
MouseClick, Middle
Return
mods()
{
Return (1 << 0) * GetKeyState("LButton")
| (1 << 1) * GetKeyState("RButton")
| (1 << 2) * GetKeyState("Shift")
| (1 << 3) * GetKeyState("Ctrl")
| (1 << 4) * GetKeyState("MButton")
| (1 << 5) * GetKeyState("XButton1")
| (1 << 6) * GetKeyState("XButton2")
}