SI苦力
我需要检查一个特定的区域是否存在我要点击的图像,并且图像会随机显示,我编写代码来检查,但是检查区域需要10秒以上,无论如何我可以缩短时间。
Settings.MinSimilarity = 0.95
Reg = Region(582,404,214,187)
img = capture(Reg)
search = True
Settings.MoveMouseDelay = 0
while search :
if Reg.exists("12.png") or Reg.exists("13.png") or Reg.exists("14.png")or Reg.exists("15.png")or Reg.exists("28.png"):
click(Reg.getLastMatch())
search = False
您可以在0
调用中添加exists()
参数。
而不是
if Reg.exists("12.png") or Reg.exists("13.png") or Reg.exists("14.png")or Reg.exists("15.png")or Reg.exists("28.png"):
你将会拥有:
if Reg.exists("12.png",0) or Reg.exists("13.png",0) or Reg.exists("14.png",0)or Reg.exists("15.png",0)or Reg.exists("28.png",0):
根据this,零参数意味着
0作为存在强制的第二个参数,只执行一次搜索并立即返回结果。它没有等待标准的3秒,所以它非常敏感。
区域越小,这将越快。
试试这个:
Reg.setAutoWaitTimeout(0.5)
这样可以将检测时间从3秒减少到0.5秒或您喜欢的值。