vb点虐 中响应鼠标 vbscript鼠标操作
如何在VB点虐 中用程序控制鼠标移动和点击
调用api
创新互联公司服务项目包括定结网站建设、定结网站制作、定结网页制作以及定结网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,定结网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到定结省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
在Visual Baisc点虐 中的声明:
Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Public Const MOUSEEVENTF_LEFTDOWN = H2 '知穗虚模拟鼠标左键按下
Public Const MOUSEEVENTF_LEFTUP = H4 ’模拟鼠标左键释放
Public Const MOUSEEVENTF_MIDDLEDOWN = H20 '模拟鼠标中间键按下
Public Const MOUSEEVENTF_MIDDLEUP = H40 '模拟鼠标中间键族睁释放
Public Const MOUSEEVENTF_RIGHTDOWN = H8 '模拟鼠标右键按下
Public Const MOUSEEVENTF_RIGHTUP = H10 '模拟鼠标右键释放
Public Const MOUSEEVENTF_MOVE = H1 '模拟鼠标指针移动搭燃
例:
mouse_event MOUSEEVENTF_LEFTDOWN,10,10,0,0
'在(10,10)模拟鼠标左键按下
VB.NET模拟鼠标问题
Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Integer, ByVal dwExtraInfo As Integer)
Dim postion1 As New Point
mouse_event(H1 Or H8000, postion1.X * 65535 / 1366, postion1.Y * 65535 / 768, 0, 0)
'按绝对位置移动鼠标
'在鼠标坐标系统中,屏幕在水平和垂直方向上均匀分割成65535×65535个单元,
'当前所用显示屏贺仔迅分辨率为1366*768
'所以要进行如上转换
mouse_event(H2, 0, 0, 0, 0) '鼠标左键按禅此下
mouse_event(H4, 0, 0, 0, 0) '鼠标戚态左键弹起
msdn上有 mouse_event 的详解,大致使用如上
VB怎么实现滚动条对鼠标中轴的响应啊?
VB可以使用子镇颂类化处理鼠标滚轮消息。
新建工程
在窗体中添加滚动条VScroll1
'窗体代码
Private Sub Form_Load()
'取得控件的句柄
hwndVS = VScroll1.hwnd
'保存smMap控件的默认窗口消息处理函数地址
OldWindowProc = GetWindowLong(VScroll1.hwnd, GWL_WNDPROC)
'将smMap控件的消息处理函数指定为自定义函数NewWindowProc
Call SetWindowLong(VScroll1.hwnd, GWL_WNDPROC, AddressOf NewWindowProc)
End Sub
添高睁加一模块:
Option Explicit
Public 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
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC = -4
Public Const WM_MOUSEWHEEL = H20A
Public OldWindowProc As Long '用来保存系统默认的窗口消息处理函数的地址
Public hwndVS As Long '用来保存控件的句柄
'自定义的消息处理函数
Public Function NewWindowProc(ByVal hwnd As Long, ByVal msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Error Resume Next
If msg = WM_MOUSEWHEEL Then
'则对鼠标滚轮事件进行处理
If wParam = -7864320 Then '向下滚动
Form1.VScroll1.Value = Form1.VScroll1.Value + 1
ElseIf wParam = 7864320 Then '向上滚动
Form1.VScroll1.Value = Form1.VScroll1.Value - 1
End If
Else
'调用默认窗口消息处理函数
NewWindowProc = CallWindowProc(OldWindowProc, hwnd, msg, wParam, lParam)
End If
End Function
vb中如何响应鼠标右击事件
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Select Case Button
Case 1
Label1.Caption = " 左"
Case 2
Label1.Caption = " 右"
Case 4
Label1.Caption = " 中"含念
End Select
End Sub
button 返回一个整数,用来标识该事件的产生是按下 ( MouseDown ) 或者释放 ( MouseUp ) 按钮引起的。button 参数是具有相高老喊应于左按钮(位 0),右按钮(位 1),以及中间按钮(位 2)的一个位字段。这些位的值分别等于 1,2,戚野和 4。其中仅有一位被设置,指示出引起该事件的那个按钮。
网页名称:vb点虐 中响应鼠标 vbscript鼠标操作
文章网址:http://myzitong.com/article/ddpjpcd.html