按键精灵吧 关注:499,936贴子:1,021,066
  • 3回复贴,共1

分享一个多点找色的封装

只看楼主收藏回复

普通的 FindMultiColor 命令只能返回找到的第一个特征,用下面的封装就可以返回多个找到的特征
Function 返回多个点的坐标数组(sx, sy, ex, ey, 主颜色,次颜色,搜索次序,相似度)
If sx = 0 and sy = 0 Then
If ex = 0 and ey = 0 Then
ex = GetScreenX()
ey = GetScreenY()
End If
End If
KeepCapture
Dim TickCount()
Dim intX,intY
Dim arrx = Array()
Dim arry = Array()
Dim num =0
Dim 范围 = 获取大小(次颜色)
For i = sx To ex Step 范围(0)
For j = sy To ey Step 范围(1)
FindMultiColor i,j,i+范围(0)-1,j+范围(1)-1, 主颜色, 次颜色, 搜索次序,相似度,intX,intY
If intX > -1 Then
arrx(num) = intX
arry(num) = intY
num = num + 1
End If
Next
Next
Dim arrxy = Array(arrx,arry,num)
返回多个点的坐标数组 = arrxy
ReleaseCapture
End Function
Function 获取大小(str)
Dim arr = Split(str,",")
Dim xy = Array()
Dim x = 0
Dim y = 0
Dim i = 0
For Each n In arr
Dim 第一个位置 = InStr(1, n, "|")
If Int(Left(n,第一个位置 - 1)) > x Then
x = Int(Left(n,Instr(1,n,"|")-1))
End If
Dim n2 = StrCut(n, 1,第一个位置)
Dim 第二个位置 = InStr(1, n2, "|")
If Int(Left(n2,第二个位置 - 1)) > y Then
y = Int(Left(n2,第二个位置 - 1))
End If
Next
xy = Array(x,y)
获取大小 = xy
End Function
Dim t = TickCount()
Dim arr = 返回多个点的坐标数组(0,0,0,0,"BAB7B4-101010", "98|0|B9B7B0-101010,98|98|B7B4AF-101010,0|98|B5B4B0-101010", 0, 0.9)
For i = 0 To arr(2)-1
TracePrint arr(0, i) & "," & arr(1, i)
Next
TracePrint TickCount() - t


IP属地:福建1楼2022-02-22 22:47回复
    谢谢 正好用到


    IP属地:湖南2楼2022-05-05 22:23
    回复
      这样 不如封两个 找色1 找色2


      IP属地:广东3楼2022-11-26 21:43
      回复
        新版有多个坐标的吧


        IP属地:重庆来自iPhone客户端5楼2022-11-30 12:24
        回复