Imports System.Reflection.Emit
Imports System.Runtime.InteropServices '需要引入这个命名空间
Imports System.Threading
Public Class Form1
Private Declare Auto Function SetCursorPos Lib “user32.dll” (ByVal x As Integer, ByVal y As Integer) As Boolean
Private Declare Sub mouse_event Lib “user32.dll” (ByVal dwFlags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As Integer)
Private Const MOUSEEVENTF_LEFTDOWN As Integer = &H2
Private Const MOUSEEVENTF_LEFTUP As Integer = &H4
Private Const WM_SETTEXT As Integer = &HC
Private Const EM_SETSEL As Integer = &HB1
Private Const WM_COPY As Integer = &H301
Private Const WM_PASTE As Integer = &H302
<DllImport("user32.dll")>
Private Shared Function GetCursorPos(ByRef lpPoint As POINTAPI) As Boolean
End Function
Private Const MOUSEEVENTF_RIGHTDOWN As Integer = &H8
Private Const MOUSEEVENTF_RIGHTUP As Integer = &H10
Private Structure POINTAPI
Public X As Integer
Public Y As Integer
End Structure
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick
Dim point As POINTAPI
GetCursorPos(point)
Label1.Text = "鼠标横坐标为:" & point.X & vbCrLf & vbCrLf & "鼠标纵坐标为:" & point.Y
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j, k, l, m, n As String
i = TextBox1.Text
j = TextBox2.Text
k = TextBox3.Text
l = TextBox4.Text
m = TextBox5.Text
n = TextBox6.Text
For a = 0 To 3
'模拟鼠标点击操作1
SetCursorPos(i, j) '将(100, 100)改为实际需要点击的坐标位置
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
SetCursorPos(i + 300, j) '将(i+300, j)向右移动鼠标到指定位置
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
SetCursorPos(i - 300, j) '将(i-300, j)向左移动鼠标到指定位置
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
'等待一段时间,确保程序已经成功打开
Thread.Sleep(1000)
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i, j As String
i = TextBox1.Text
j = TextBox2.Text
'模拟鼠标点击操作1
SetCursorPos(i, j) '将(100, 100)改为实际需要点击的坐标位置
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
SetCursorPos(i - 300, j) '将(i-300, j)向左移动鼠标到指定位置
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
SetCursorPos(i + 300, j) '将(i+300, j)向右移动鼠标到指定位置
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
SetCursorPos(i, j - 300) '将(i, j-300)向上移动鼠标到指定位置
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
SetCursorPos(i, j + 300) '将(i, j+300)向下移动鼠标到指定位置
'等待一段时间,确保程序已经成功打开
Thread.Sleep(800)
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
'等待一段时间,确保程序已经成功打开
Thread.Sleep(1000)
End Sub
End Class