0

I'm created two variables that play different iimPlay functions. However, the code always execute the first if statement and ignore the 2nd statement.

Main.js

var ReturnCode = iimPlay("win.iim");  
var returncode2 = iimPlay("lose.iim"); //
if (ReturnCode = 1) {         *//when returncode =1 means complete execute*
iimPlay("reset.iim");
} 

if (returncode2 = 1 ) {
iimPlay("double.iim");
}

Win.iim

IMAGESEARCH POS=1 IMAGE=C:\win.png CONFIDENCE=65 

imagesearch will always execute no matter match or not

Lose.iim

IMAGESEARCH POS=1 IMAGE=C:\lose.png CONFIDENCE=65  

imagesearch will always execute no matter match or not

HTML tag

<div id="game-result" class="balance-change fail">
<span id="result-text">
LOST
</span> </div>

Problem : Whenever the iimPlay("win.iim") detects win or lose image, it still execute the first statement as fact that lose image should execute the second if statement.

4

2 回答 2

1

而不是使用图像搜索尝试

TAG POS=1 TYPE=DIV ATTR=CLASS:image_you_are_looking_for CONTENT=EVENT:MOUSEOVER


TAG POS=1 TYPE=DIV  ATTR=CLASS:second_image_you_are_looking_for CONTENT=EVENT:MOUSEOVER

如果它不存在,这种方式将返回错误代码。

这也是错误。

if (returncode2 = 1 ) { }

您将值 1 设置为 returncode2 而不是将其与 1 进行比较。正确的是

if (returncode2 == 1 ) { }

更好的是:

if (returncode2 > 0 ) { }

其他返回码也一样。修复这些并重试。

于 2013-11-06T17:28:36.077 回答
0

你需要始终小心这个EQUAL标志。在 Javascript 中进行比较,您使用=====. 您的代码有归属,并且永远是TRUE;这就是为什么它总是被执行。有关 javascript 平等的详细信息,请参阅这篇文章

于 2013-11-05T22:57:06.767 回答