- 幼儿园
- 9473054
- 2
- 0
- 7 朵
- 21 个
- 11 个
- 0
- 2025-07-22
|
1#
t
T
发表于 2025-08-01 12:07
|
|只看楼主
// 按键精灵脚本 - 随机乱序数字验证码自动点击输入 // 定义数字图片路径(需提前截取0-9数字图片放入Attachment文件夹) Dim numImage(9) For i = 0 To 9 numImage(i) = "Attachment:\num" & i & ".bmp" Next // 主程序 Call Main() Sub Main() // 1. 定义验证码区域(根据实际调整坐标) // 适用于2014以前版本 Dim areaX1, areaY1, areaX2, areaY2 areaX1 = 100 areaY1 = 200 areaX2 = 300 areaY2 = 400 // 2. 初始化数组存储数字位置 Dim numPositions(9, 2) // [0]=x坐标, [1]=y坐标, [2]=数字值 // 3. 识别所有数字位置 If FindAllNumbers(capX1, capY1, capX2, capY2, numPositions) = False Then TracePrint "识别数字失败!" Exit Sub End If // 4. 按正确顺序点击数字(示例为升序) ClickInOrder(numPositions) End Sub
// 识别所有数字位置函数 Function FindAllNumbers(x1, y1, x2, y2, ByRef positions) Dim foundCount foundCount = 0 For i = 0 To 9 Dim foundX, foundY FindPic x1, y1, x2, y2, numImage(i), 0.9, foundX, foundY If foundX > 0 Then positions(foundCount, 0) = foundX // x坐标 positions(foundCount, 1) = foundY // y坐标 positions(foundCount, 2) = i // 数字值 foundCount = foundCount + 1 TracePrint "找到数字" & i & " 位置: " & foundX & "," & foundY End If Next If foundCount < 4 Then // 假设至少4个数字 TracePrint "找到的数字太少,只有" & foundCount & "个" Return False End If // 调整数组大小(仅保留找到的数字) ReDim Preserve positions(foundCount-1, 2) Return True End Function
// 按顺序点击数字(示例为升序) Function ClickInOrder(positions) // 1. 对数字按值排序(升序) SortNumbers(positions) // 2. 依次点击数字 For i = 0 To UBound(positions, 1) MoveTo positions(i, 0), positions(i, 1) Delay 200 LeftClick 1 Delay 300 TracePrint "点击数字: " & positions(i, 2) Next End Function
// 数字排序函数(按数字值升序) Function SortNumbers(ByRef positions) Dim i, j, tempX, tempY, tempVal For i = 0 To UBound(positions, 1) - 1 For j = i + 1 To UBound(positions, 1) If positions(i, 2) > positions(j, 2) Then // 交换x坐标 tempX = positions(i, 0) positions(i, 0) = positions(j, 0) positions(j, 0) = tempX // 交换y坐标 tempY = positions(i, 1) positions(i, 1) = positions(j, 1) positions(j, 1) = tempY // 交换数字值 tempVal = positions(i, 2) positions(i, 2) = positions(j, 2) positions(j, 2) = tempVal End If Next Next End Function 放到按键精灵里面就会出现以下错误提示: 语法错误:脚本 点击型随机数字验证码自动识别自动点击验证 ,第51行,第5个字符:(错误码0)没有找到合法的符号。 语法错误:脚本 点击型随机数字验证码自动识别自动点击验证 ,第48行,第19个字符:(错误码0)没有找到合法的符号。 语法错误:脚本 点击型随机数字验证码自动识别自动点击验证 ,第48行,第19个字符:(错误码0)没有找到合法的符号。 语法错误:脚本 点击型随机数字验证码自动识别自动点击验证 ,第48行,第5个字符:(错误码0)没有找到合法的符号。跪请大神赐教!!!
|