vb怎么能让鼠标移动
解决时间 2021-07-20 02:08
- 提问者网友:不爱我么
- 2021-07-19 01:14
最佳答案
- 五星知识达人网友:长青诗
- 2021-07-19 01:32
vc下有mouse_event
vb应该也有 baidu了一下 还真是有
一下非原创 出处 http://wenwen.sogou.com/z/q718884064.htm
Private 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)
Private Const MOUSEEVENTF_ABSOLUTE = &H8000 '指定鼠标使用绝对坐标系,此时,屏幕在水平和垂直方向上均匀分割成65535×65535个单元
Private Const MOUSEEVENTF_MOVE = &H1 '移动鼠标
Private Const MOUSEEVENTF_LEFTDOWN = &H2 '模拟鼠标左键按下
Private Const MOUSEEVENTF_LEFTUP = &H4 '模拟鼠标左键抬起
Private Const SW = 1024
Private Const SH = 768
Private Sub Screen_Click(ByVal x As Long, ByVal y As Long)
mw = x / SW * 65535
mh = y / SH * 65535
mouse_event MOUSEEVENTF_ABSOLUTE + MOUSEEVENTF_MOVE, mw, mh, 0, 0
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub Command1_Click()
Screen_Click 512, 384 '点击Command1之后,模拟点击屏幕中间
End Sub
Private Sub Command2_Click()
Print Rnd
End Sub
Private Sub Form_Load()
Me.Height = Me.Width
Command2.Move (Me.ScaleWidth - Command2.Width) / 2, (Me.ScaleHeight - Command2.Height) / 2
End Sub
全部回答
设定鼠标位置的API声明:
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private command1_click()
dim w
w=SetCursorPos( X, Y) '(X,Y)为坐标,单位为 Pixel(像素)
end sub
- 2楼网友:猎心人
- 2021-07-19 02:18
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Sub Command1_Click()
Call SetCursorPos(0, 0)
End Sub
我要举报
大家都在看
推荐资讯