vb定义鼠标全局快捷键
用vb定义全局快捷键,想做到这样:按一下鼠标中键,则sendkeys"man"然后单击一下鼠标左键滚动一下滑轮,则单击一下鼠标左键然后单击一下鼠标右键,然后sendkey...
用vb定义全局快捷键,想做到这样:
按一下鼠标中键,则sendkeys "man"然后单击一下鼠标左键
滚动一下滑轮,则单击一下鼠标左键然后单击一下鼠标右键,然后sendkeys " ~"
答详细多多送分,请达人帮帮忙吧。
参考资料:
http://zhidao.baidu.com/question/112636768.html
http://zhidao.baidu.com/question/65130841.html 展开
按一下鼠标中键,则sendkeys "man"然后单击一下鼠标左键
滚动一下滑轮,则单击一下鼠标左键然后单击一下鼠标右键,然后sendkeys " ~"
答详细多多送分,请达人帮帮忙吧。
参考资料:
http://zhidao.baidu.com/question/112636768.html
http://zhidao.baidu.com/question/65130841.html 展开
展开全部
Public 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)
'声明鼠标API函数
' dwFlags Long,下表中标志之一或它们的组合
' dx,dy Long,根据MOUSEEVENTF_ABSOLUTE标志,指定x,y方向的绝对位置或相对位置
' cButtons Long,没有使用
' dwExtraInfo Long,没有使用
' dwFlags常数 意义
' MOUSEEVENTF_MOVE &H1,移动鼠标
' MOUSEEVENTF_LEFTDOWN &H2,模拟鼠标左键按下
' MOUSEEVENTF_LEFTUP &H4,模拟鼠标左键抬起
' MOUSEEVENTF_RIGHTDOWN &H8,模拟鼠标右键按下
' MOUSEEVENTF_RIGHTUP &H10,模拟鼠标右键抬起
' MOUSEEVENTF_MIDDLEDOWN &H20,模拟鼠标中键按下
' MOUSEEVENTF_MIDDLEUP &H40,模拟鼠标中键抬起
' MOUSEEVENTF_ABSOLUTE &H8000,标示是否采用绝对坐标
Public Const MOUSEEVENTF_MOVE = &H1
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_ABSOLUTE = &H8000
Public Sub LeftClick()
'左键按下
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
DoEvents
'左键放开
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
DoEvents
End Sub
Public Sub RightClick()
'右键按下
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
DoEvents
'右键放开
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
DoEvents
End Sub
Public Sub MiddleClick()
'中键按下
mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
DoEvents
'中键放开
mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
DoEvents
End Sub
Public Sub MoveMouse(X As Long, Y As Long)
Dim SCR_W As Long
Dim SCR_H As Long
SCR_W = Screen.Width / 15
SCR_H = Screen.Height / 15
mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_MOVE, Int(X / SCR_W * 65535), Int(Y / SCR_H * 65535), 0, 0
End Sub
把这段代码写在一个Module里面,随时可以调用(双击的话调用两次)
调用方法:
LeftClick
MiddleClick
RightClick
MoveMouse 横坐标,纵坐标
(ByVal dwFlags As Long, ByVal dx As Long, _
ByVal dy As Long, ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)
'声明鼠标API函数
' dwFlags Long,下表中标志之一或它们的组合
' dx,dy Long,根据MOUSEEVENTF_ABSOLUTE标志,指定x,y方向的绝对位置或相对位置
' cButtons Long,没有使用
' dwExtraInfo Long,没有使用
' dwFlags常数 意义
' MOUSEEVENTF_MOVE &H1,移动鼠标
' MOUSEEVENTF_LEFTDOWN &H2,模拟鼠标左键按下
' MOUSEEVENTF_LEFTUP &H4,模拟鼠标左键抬起
' MOUSEEVENTF_RIGHTDOWN &H8,模拟鼠标右键按下
' MOUSEEVENTF_RIGHTUP &H10,模拟鼠标右键抬起
' MOUSEEVENTF_MIDDLEDOWN &H20,模拟鼠标中键按下
' MOUSEEVENTF_MIDDLEUP &H40,模拟鼠标中键抬起
' MOUSEEVENTF_ABSOLUTE &H8000,标示是否采用绝对坐标
Public Const MOUSEEVENTF_MOVE = &H1
Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Public Const MOUSEEVENTF_RIGHTDOWN = &H8
Public Const MOUSEEVENTF_RIGHTUP = &H10
Public Const MOUSEEVENTF_MIDDLEDOWN = &H20
Public Const MOUSEEVENTF_MIDDLEUP = &H40
Public Const MOUSEEVENTF_ABSOLUTE = &H8000
Public Sub LeftClick()
'左键按下
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
DoEvents
'左键放开
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
DoEvents
End Sub
Public Sub RightClick()
'右键按下
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
DoEvents
'右键放开
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
DoEvents
End Sub
Public Sub MiddleClick()
'中键按下
mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
DoEvents
'中键放开
mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
DoEvents
End Sub
Public Sub MoveMouse(X As Long, Y As Long)
Dim SCR_W As Long
Dim SCR_H As Long
SCR_W = Screen.Width / 15
SCR_H = Screen.Height / 15
mouse_event MOUSEEVENTF_ABSOLUTE Or MOUSEEVENTF_MOVE, Int(X / SCR_W * 65535), Int(Y / SCR_H * 65535), 0, 0
End Sub
把这段代码写在一个Module里面,随时可以调用(双击的话调用两次)
调用方法:
LeftClick
MiddleClick
RightClick
MoveMouse 横坐标,纵坐标
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询