你已经有了“鼠标右键点击的事件”
我们提供的服务有:网站设计制作、成都网站建设、微信公众号开发、网站优化、网站认证、武义ssl等。为成百上千企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的武义网站制作公司
说明你肯定已经有了if e.button=windows.forms.mousebuttons.right then
你只需要找到这条语句,通常这句话应该在你的mouseclick事件中。
这条语句改成
if e.button=windows.forms.mousebuttons.left or e.button=windows.forms.mousebuttons.right then
就可以了!
^_^
Private Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = H2 ' 左键按下Private Const MOUSEEVENTF_LEFTUP = H4 ' 左键抬起
Private Const MOUSEEVENTF_MOVE = H1 ' 鼠标移动 在需要操作鼠标的地方调用如下两句
Call Mouse_Event(MOUSEEVENTF_LEFTDown,10,10,0,0) '让鼠标在10,10位置按下 Call Mouse_Event(MOUSEEVENTF_LEFTUP,10,10,0,0) '让鼠标在10,10位置抬起这两句代码的操作就相当于我们单击一次鼠标(先按下然后抬起)如果你需要做移动鼠标到某个位置的话,可以用这个API来实现(用Mouse_Event里的MOUSEEVENTF_MOVE需要将你的相对屏幕的坐标按屏幕65535X65535的比例进行转换成绝对座标才可以) Private Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long
在需要移动鼠标的地方调用如下:Call SetCursorPos(10,10) '这里的10,10就是屏幕相对当前分辨率而言的绝对坐标
调用api
在Visual Baisc.net中的声明:
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)模拟鼠标左键按下
直接把消息发送给TextBox。
Dim x As Integer, y As Integer
x = 100
y = 100
PostMessage(TextBox1.Handle.ToInt32, WM_LBUTTONDOWN, MK_LBUTTON, MakeInteger(x, y))
PostMessage(TextBox1.Handle.ToInt32, WM_LBUTTONUP, MK_LBUTTON, MakeInteger(x, y))