先添加一模块,在其中声明:
Declare Function SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
在窗体的代码中调用:
SetCursorPos X, Y '鼠标移动到屏幕坐标 X,Y(单位是像素)
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 1000, 1000
End Sub