Skip to content

Commit

Permalink
fix: todo fix sendinput
Browse files Browse the repository at this point in the history
  • Loading branch information
snomiao committed Jan 12, 2022
1 parent b97028d commit e96b4e8
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions Modules/01.1-插件-鼠标模拟.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,19 @@ SendInput_MouseMsg32(dwFlag, mouseData := 0)
NumPut(dwFlag, sendData, 16, "UInt")
DllCall("SendInput", "UInt", 1, "Str", sendData, "UInt", 28)
}

ScrollMouse(dx, dy){
if (TMouse_SendInputAPI) {
SendInput_ScrollMouse(dx, dy)
} else {
PostMessage_ScrollMouse(dx, dy)
}
}
PostMessage_ScrollMouse(dx, dy){
WM_MOUSEWHEEL := 0x020A
WM_MOUSEWHEELH := 0x020E
_:= dy && PostMessageForScroll(WM_MOUSEWHEEL, -dy)
_:= dx && PostMessageForScroll(WM_MOUSEWHEELH, dx)
}
SendInput_ScrollMouse(dx, dy)
{
; get cursor pos
Expand All @@ -102,25 +114,27 @@ SendInput_ScrollMouse(dx, dy)
; scroll by system input message
MOUSEEVENTF_WHEEL := 0x0800
MOUSEEVENTF_HWHEEL := 0x1000
if (dx) {
size := A_PtrSize+4*4+A_PtrSize
VarSetCapacity(mi, size, 0)
NumPut(x, mi, A_PtrSize, "Int") ; LONG dx
NumPut(y, mi, A_PtrSize+4, "Int") ; LONG dy
NumPut(dx, mi, A_PtrSize+4+4, "Int") ; DWORD mouseData
NumPut(MOUSEEVENTF_HWHEEL, mi, A_PtrSize+4+4+4, "UInt") ; DWORD dwFlags
DllCall("SendInput", "UInt", 1, "Ptr", &mi, "Int", size )
}
if (dy) {
size := A_PtrSize+4*4+A_PtrSize*2
VarSetCapacity(mi, size, 0)
NumPut(x, mi, A_PtrSize, "Int") ; LONG dx
NumPut(y, mi, A_PtrSize+4, "Int") ; LONG dy
NumPut(dy, mi, A_PtrSize+4+4, "Int") ; DWORD mouseData
NumPut(-dy, mi, A_PtrSize+4+4, "Int") ; DWORD mouseData
NumPut(MOUSEEVENTF_WHEEL, mi, A_PtrSize+4+4+4, "UInt") ; DWORD dwFlags
DllCall("SendInput", "UInt", 1, "Ptr", &mi, "Int", size )
; perf_timing()
}
if (dx) {
; todo fix sendinput
PostMessage_ScrollMouse(dx, 0)
; size := A_PtrSize+4*4+A_PtrSize
; VarSetCapacity(mi, size, 0)
; NumPut(x, mi, A_PtrSize, "Int") ; LONG dx
; NumPut(y, mi, A_PtrSize+4, "Int") ; LONG dy
; NumPut(dx * 120, mi, A_PtrSize+4+4, "Int") ; DWORD mouseData
; NumPut(MOUSEEVENTF_HWHEEL, mi, A_PtrSize+4+4+4, "UInt") ; DWORD dwFlags
; DllCall("SendInput", "UInt", 1, "Ptr", &mi, "Int", size )
}
}

SendInput_MouseMove(x, y)
Expand Down Expand Up @@ -201,10 +215,7 @@ SendInput_MouseMove(x, y)
if (状态 != "移动") {
return
}
WM_MOUSEWHEEL := 0x020A
WM_MOUSEWHEELH := 0x020E
_:= dy && 滚轮消息发送(WM_MOUSEWHEEL, -dy)
_:= dx && 滚轮消息发送(WM_MOUSEWHEELH, dx)
ScrollMouse(dx, dy)
}
滚轮自动控制(dx, dy, 状态){
if (状态 != "移动") {
Expand All @@ -227,7 +238,7 @@ SendInput_MouseMove(x, y)
KeyWait f
SendEvent {Blind}{MButton Up}
; 关闭滚轮自动
if(滚轮自动.横速 || 滚轮自动.纵速) {
if (滚轮自动.横速 || 滚轮自动.纵速) {
滚轮自动.止动()
滚轮自动控制(0, 0, "止动")
}
Expand All @@ -236,16 +247,9 @@ SendInput_MouseMove(x, y)
if (状态 != "移动") {
return
}
WM_MOUSEWHEEL := 0x020A
WM_MOUSEWHEELH := 0x020E
if (!TMouse_SendIputAPI) {
SendInput_ScrollMouse(dx, -dy)
} else {
_:= dy && 滚轮消息发送(WM_MOUSEWHEEL, -dy)
_:= dx && 滚轮消息发送(WM_MOUSEWHEELH, dx)
}
ScrollMouse(dx, dy)
}
滚轮消息发送(msg, zDelta){
PostMessageForScroll(msg, zDelta){
; 目前还不支持UWP
CoordMode, Mouse, Screen
MouseGetPos, x, y, wid, fcontrol
Expand Down Expand Up @@ -353,4 +357,4 @@ $*q:: CapsLockX_鼠标左键按下("q")
*r:: 滚轮模拟.上按("r")
*f:: 滚轮模拟.下按("f")
*[:: 滚轮模拟.左按("[")
*]:: 滚轮模拟.右按("]")
*]:: 滚轮模拟.右按("]")

0 comments on commit e96b4e8

Please sign in to comment.