3

I currently make a iMacro script that use ImageSearch to find the image and perform other function. If the image1 match imagesearch then perform task1, else if perform task2.

If IMAGESEARCH POS=1 IMAGE=IMAGE1.png CONFIDENCE=65
   TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:bet-amount CONTENT=0.01
   TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:bet-bt

Else If IMAGESEARCH POS=1 IMAGE=IMAGE2.png CONFIDENCE=65
   TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:bet-multiplier
   TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:bet-bt

How can I make the if statement ?

1
  • there is no IF ELSE statement in imacros Commented Oct 31, 2013 at 8:01

2 Answers 2

3

You have to use JavaScript scripting. You have an example here

Loop in Imacros using Javascript

In your case this would be first macro

IMAGESEARCH POS=1 IMAGE=IMAGE1.png CONFIDENCE=65

This would be second macro

IMAGESEARCH POS=1 IMAGE=IMAGE2.png CONFIDENCE=65

This would be third macro.

   TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:bet-amount CONTENT=0.01
   TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:bet-bt

And this would be fourth macro.

TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:bet-multiplier
   TAG POS=1 TYPE=BUTTON:SUBMIT ATTR=ID:bet-bt

So this is how it's supposed to look like.

if(iimPlay(macro1)>0)
{
iimPlay(macro3)
}
else if(iimPlay(macro2)>0)
{
iimPlay(macro4)
}
Sign up to request clarification or add additional context in comments.

3 Comments

I got imacro installed in my firefox and I'm using iMacros Browser V8.0. However, I got this Error -1100: Can not parse macro line: if(iimPlay("macro1.iim")>0)
Why Firefox imacro panel shows js file but iMacro Browser does not ?
1) Place the macro1 alongside #Current.iim file 2) I don't know the second question. Use FireFox addon. It's also very good.
1

"there is no IF ELSE statement in imacros – Bestmacros Oct 31 '13 at 8:01"

=> Indeed, but "You have to use JavaScript scripting." is incorrect...! You can achieve some Conditional Behaviour like in this Case in pure '.iim':

SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0

IMAGESEARCH POS=1 IMAGE=IMAGE1.png CONFIDENCE=65
SET ClickAmount EVAL("var y='{{!IMAGEY}}'; var z; if(y>0){z=1;} else{z=0;}; z;")
TAG POS={{ClickAmount}} TYPE=INPUT:TEXT ATTR=ID:bet-amount CONTENT=0.01
TAG POS={{ClickAmount}} TYPE=BUTTON:SUBMIT ATTR=ID:bet-bt

IMAGESEARCH POS=1 IMAGE=IMAGE2.png CONFIDENCE=65
SET ClickMultiplier EVAL("var y='{{!IMAGEY}}', a='{{ClickAmount}}'; var z; if(a==1){z=0;} else if(y>0){z=1;} else{z=0;}; z;")
TAG POS={{ClickMultiplier}} TYPE=BUTTON:SUBMIT ATTR=ID:bet-multiplier
TAG POS={{ClickMultiplier}} TYPE=BUTTON:SUBMIT ATTR=ID:bet-bt

=> All the 'IF/ELSE' Logic in one single '.iim' Macro, very similar to @OP's original Script, and will work directly in iMB or IE, instead of using 4 Scripts requiring a main '.js' Script that will only work in FF...!

(Not tested, I've never used 'IMAGESEARCH' as I only use the free Add-on (with FF), according to the Wiki, '!IMAGEX' and '!IMAGEY' are supposed to hold the Coordinates if the Image is found and I suppose valid Coordinates must be >0, at least for '!IMAGEY'. The '!IMAGEX' and '!IMAGEY' Variables may need to be reset to 'NULL' before the 2nd 'IMAGESEARCH' if it doesn't occur automatically... (I cannot test...))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.