vb如何控制鼠标移动。例如在text1、text2中分别输入x、y坐标。单击按钮然后鼠标指针移动到相应的位置
4个回答
展开全部
Option Explicit
Private Declare Function SetCursorPos Lib "user32" ( _
ByVal x As Long, _
ByVal y As Long _
) As Long
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_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
SetCursorPos Text1.Text , Text2.Text
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Declare Function SetCursorPos Lib "user32" ( _
ByVal x As Long, _
ByVal y As Long _
) As Long
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_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Sub Command1_Click()
SetCursorPos Text1.Text , Text2.Text
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
展开全部
Private Declare Function SetCursorPos Lib "user32" _
(ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_Click()
SetCursorPos Val(Text1), Val(Text2)
End Sub
(ByVal X As Long, ByVal Y As Long) As Long
Private Sub Command1_Click()
SetCursorPos Val(Text1), Val(Text2)
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim P As POINTAPI
P.x = Val(Text1)
P.y = Val(Text2)
SetCursorPos P.x, P.y
End Sub
Private Type POINTAPI
x As Long
y As Long
End Type
Private Sub Command1_Click()
Dim P As POINTAPI
P.x = Val(Text1)
P.y = Val(Text2)
SetCursorPos P.x, P.y
End Sub
追问
直接用 SetCursorPos text1.text,text2.text 不行吗??
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
两种方法:
1,全局都能用得上的模块.
Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long '鼠标移动位置申明.
'然后这是窗口用计时器
Private Sub Timer1_Timer()
Dim z As POINTAPI
GetCursorPos z
Text1.Text = "MouseX:" & z.x & Space(5) & "MouseY:" & z.y '鼠标位置
End Sub
2,窗口内部的XY位置
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = "MouseX:" & X & Space(5) & "MouseY:" & Y '鼠标位置
End Sub
1,全局都能用得上的模块.
Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long '鼠标移动位置申明.
'然后这是窗口用计时器
Private Sub Timer1_Timer()
Dim z As POINTAPI
GetCursorPos z
Text1.Text = "MouseX:" & z.x & Space(5) & "MouseY:" & z.y '鼠标位置
End Sub
2,窗口内部的XY位置
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Text1.Text = "MouseX:" & X & Space(5) & "MouseY:" & Y '鼠标位置
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询