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 ?

Chozo Qhai
  • 283
  • 2
  • 10
  • 19

2 Answers2

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)
}
Community
  • 1
  • 1
edinvnode
  • 3,497
  • 7
  • 30
  • 53
  • 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) – Chozo Qhai Nov 01 '13 at 02:15
  • Why Firefox imacro panel shows js file but iMacro Browser does not ? – Chozo Qhai Nov 01 '13 at 03:08
  • 1) Place the macro1 alongside #Current.iim file 2) I don't know the second question. Use FireFox addon. It's also very good. – edinvnode Nov 01 '13 at 05:17
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...))

chivracq
  • 667
  • 9
  • 24