我正在使用ImageSearch.au3,没关系,但我想多次搜索同一张图片,直到它不再存在。
图像: link 。如果我点击按钮“dona”,我就会把它隐藏起来。所以,这是我的来源:
#include <ImageSearch.au3>
$x = 0
$y = 0
#Region simple search
#cs
$res = _imagesearch('dona.png',1,$x,$y,100)
If $res = 1 Then
MouseMove($x,$y,100)
MouseClick("left")
Else
MsgBox(0,'Info','richieste presenti')
EndIf
#ce
#EndRegion
#Region Search for more images with call waiting
Dim $myPics[10]
$myPics[0] = 2
$myPics[1] = 'dona.png'
$myPics[2] = 'altre.png'
$res = _WaitForImagesSearch($myPics,5,1,$x,$y,100)
Switch $res
Case 0
MsgBox(0,'','nessuno trovato')
Case 1
MouseMove($x,$y,100)
MouseClick("left")
MouseClick("left")
MsgBox(0,'','donazione trovata')
Case 2
MouseMove($x,$y,100)
mouseclick("left")
MsgBox(0,'','richieste trovate')
EndSwitch
问题是当有2个或更多图像“DONA”时
如何搜索每张图片?
编辑:我写了这个:Dim $myPics[10]
$myPics[0] = 2
$myPics[1] = 'dona.png'
$myPics[2] = 'altre.png'
$res = _WaitForImagesSearch($myPics,5,1,$x,$y,100)
Switch $res
Case 0
MsgBox(0,'','nessuno trovato')
Case 1
While True = True
Sleep(300) ;protect the CPU from throttling
$res = _ImageSearch('dona.png', 1, $x, $y, 100)
If $res = 1 Then
MouseClick("left",$x, $y)
ElseIf $res=0
sleep(300)
$res=_imagesearch('altre.png',1 , $x, $y, 100) Then
MouseClick("left",$x, $y)
endif
Wend
但它找不到'altre.png'。
答案 0 :(得分:0)
基于表达式循环。
While <expression>
statements
...
WEnd
<强>说明强>
虽然...... WEnd语句可以嵌套。
表达式之前已经过测试 执行循环,使循环执行零次或多次 要创建无限循环,可以使用非零数字作为 表达
您的示例的无限循环
While True = True
Sleep(300) ;protect the CPU from throttling
$res = _ImageSearch($Img1, 1, $x, $y, 100)
If $res = 1 Then
MouseClick("left",$x, $y)
EndIf
Wend
自动确实很容易学习。这主要是因为它有一个非常好的 写得好的帮助文件。它包含每个单独的代码示例 功能
此外,还有一个很棒的自动社区forum。
这个论坛已经开始了 很长一段时间都是机会,你的问题可能就是 已经回答。
在询问前始终使用搜索。