'sleep函数
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
'获取鼠标坐标
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
'移动鼠标
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 Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Const EM_REPLACESEL = &HC2
Private f As Integer '文件号
Private fileContent() As String '文件内容数组
Private currentLine As Integer '当前行号
Private Sub Command3_Click()
Dim i, j, k, l, m, n As String
Dim a
Dim z As Object
Set z = CreateObject("WScript.Shell")
i = Text2.Text
j = Text3.Text
k = Text4.Text
l = Text5.Text
m = Text6.Text
n = Text7.Text
Call Command5_Click
Sleep 500
SetCursorPos i, j
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 500
z.SendKeys "^V" ' 按下Ctrl+V粘贴
Sleep 500
SetCursorPos k, l
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 500
SetCursorPos m, n
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 500
For a = 0 To 8
Call Command5_Click
Sleep 500
SetCursorPos i, j
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 500
z.SendKeys "{BackSpace 5}" ' 按下BackSpace删除
Sleep 500
z.SendKeys "^V" ' 按下Ctrl+V粘贴
Sleep 500
SetCursorPos k, l
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 500
SetCursorPos m, n
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
Sleep 500
Next
End Sub
Private Sub Command6_Click()
Dim m, n As String
m = Text6.Text
n = Text7.Text
SetCursorPos m, n
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub Form_Load()
'打开文本文件
f = FreeFile
Open "C:\Users\28261\Desktop\组合.txt" For Input As f '替换为您的文本文件路径
'将文件内容读取到数组中
Dim lineCount As Integer
lineCount = 0
Do Until EOF(f)
ReDim Preserve fileContent(0 To lineCount)
Input #f, fileContent(lineCount)
lineCount = lineCount + 1
Loop
'关闭文本文件
Close f
'初始化当前行号
currentLine = 0
Text1.Text = "C:\Users\28261\Desktop\文本框密码登录程序.exe"
End Sub
Private Sub Command1_Click()
Dim i, j As String
i = Text2.Text
j = Text3.Text
SetCursorPos i, j
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub Command2_Click()
Dim i As String
i = Text1.Text
Shell i, vbNormalFocus
End Sub
Private Sub Command4_Click()
Dim k, l As String
k = Text4.Text
l = Text5.Text
SetCursorPos k, l
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
End Sub
Private Sub Command5_Click()
'将当前行复制到剪贴板
Clipboard.Clear '清空剪贴板中的内容
Clipboard.SetText fileContent(currentLine) '设置剪贴板的内容为当前行
'更新当前行号
currentLine = currentLine + 1
If currentLine >= UBound(fileContent) + 1 Then
currentLine = 0 '已读取完所有行则重置为第一行
End If
End Sub
Private Sub Timer1_Timer()
Dim Point As POINTAPI
GetCursorPos Point
Label1.Caption = "鼠标坐标:" & vbCrLf & vbCrLf & "鼠标横坐标为:" & Point.X & vbCrLf & "鼠标纵坐标为:" & Point.Y
End Sub