| |
如果另外加些扫死区部分的命令,就可以消除上面脚本的死区,参考脚本如下:
VBS y0=0
VBS Dim x(),y()
//找到的图片横坐标和纵坐标分别存在x()数组和y()数组中
VBS i=0
//找到的图片数量存在变量i中
VBS pd=1
VBS Dim pd1
VBS Dim x01
VBSCall FindPic(0,y0,1024,768,"发.bmp",1,xz,yz)
If xz<0 or yz<0
MessageBox "没找到图形"
EndScript
EndIf
//9到13行可以不要
While pd=1
VBSCall FindPic(0,y0,1024,768,"发.bmp",1,xz,yz)
If xz>=0 and yz>=0
VBS ReDim Preserve x(i)
VBS ReDim Preserve y(i)
VBS x(i)=xz
VBS y(i)=yz
VBS i=i+1
VBS y0=yz+1
VBS x01=xz+1
VBS pd1=1
While pd1=1
VBSCall FindPic(x01,yz,1024,yz+12,"发.bmp",1,xz1,yz1)
//12是图片"发.bmp"的高度
If xz1>=0 and yz1>=0
VBS ReDim Preserve x(i)
VBS ReDim Preserve y(i)
VBS x(i)=xz1
VBS y(i)=yz1
VBS i=i+1
VBS x01=xz1+1
Else
VBS pd1=0
EndIf
EndWhile
Else
VBS pd=0
EndIf
EndWhile
//下面的命令是用于显示找图结果
VBSCall RunApp("notepad.exe")
Delay 1000
VBS n=0
While n<i
SayString x(n)
SayString ","
SayString y(n)
SayString "|"
VBS n=n+1
EndWhile
SayString i
此脚本完全消除了死区,但找图速度比前面的脚本慢点。用同样的方法也可以解决找色的问题。
|
|