请教,如何用vb实现模拟鼠标中键滚动
展开全部
可以通过hook ,但是调试的时候IDE容易挂掉,记住保存
下面是模块代码
Option Explicit
'模块代码
'***********************************************************
'mMouseWheel
'鼠标滚轮的事件检测
'***********************************************************
Private Declare Function CallWindowProc Lib "User32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Const GWL_WNDPROC = -4
Private Const WM_MOUSEWHEEL = &H20A
Global lpPrevWndProcA As Long
Public bMouseFlag As Boolean '鼠标事件激活标志
Public Sub HookMouse(ByVal hWnd As Long)
lpPrevWndProcA = SetWindowLong(hWnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnHookMouse(ByVal hWnd As Long)
SetWindowLong hWnd, GWL_WNDPROC, lpPrevWndProcA
End Sub
Private Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case uMsg
Case WM_MOUSEWHEEL '滚动
Dim wzDelta, wKeys As Integer
'wzDelta传递滚轮滚动的快慢,该值小于零表示滚轮向后滚动(朝用户方向),
'大于零表示滚轮向前滚动(朝显示器方向)
wzDelta = HIWORD(wParam)
'wKeys指出是否有CTRL=8、SHIFT=4、鼠标键(左=2、中=16、右=2、附加)按下,允许复合
wKeys = LOWORD(wParam)
'--------------------------------------------------
If wzDelta < 0 Then
小于零表示滚轮向后滚动(朝用户方向)
Else
'大于零表示滚轮向前滚动(朝显示器方向)
End If
'If GetActiveWindow() = F_set.hWnd Then
'End If
'--------------------------------------------------
Case Else
WindowProc = CallWindowProc(lpPrevWndProcA, hw, uMsg, wParam, lParam)
End Select
End Function
Private Function HIWORD(LongIn As Long) As Integer
HIWORD = (LongIn And &HFFFF0000) \ &H10000 '取出32位值的高16位
End Function
Private Function LOWORD(LongIn As Long) As Integer
LOWORD = LongIn And &HFFFF& '取出32位值的低16位
End Function
接插世界网(上海住歧电子科技有限公司)_
2022-05-17 广告
2022-05-17 广告
焊接式的接插件用于电流较小,发热较少的场合,否则过热效导致焊锡熔化,有发生短路的危险。压接的一般用于导线头,也可用于无法焊接或不适于焊接比较高热的场合。 可以订做,不过尽量选择标准的插头,以免增加成本。通用品是量产的,便宜。买卖接插件,就上...
点击进入详情页
本回答由接插世界网(上海住歧电子科技有限公司)_提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询