IF Else statements in Imacros

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.
Post Reply
TimFrazer
Posts: 3
Joined: Tue Nov 08, 2011 6:12 pm

IF Else statements in Imacros

Post by TimFrazer » Tue Nov 08, 2011 11:38 pm

Hi Everyone!

I'm trying to create an Imacro that will iterate down a page.

1) IF section of that order has the word "groupon" THEN click button follow the rest of the script
2) ELSE section does not have the word "groupon" SKIP
3) loop until loop is finished- set by user.

EXAMPLE
https://docs.google.com/open?id=0B8cWq0 ... JkOTFhYmUz

Code: Select all

TAB T=1
URL GOTO=https://www.shopatron.com/mfg/orders/assigned_orders
IF { TAG POS=1 TYPE=STRONG ATTR=TXT:Groupon* }
THEN {
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:assign_ship_* ATTR=NAME:return_btn_*
TAG POS=1 TYPE=SELECT FORM=NAME:bidform ATTR=NAME:mfg_loc CONTENT=%46
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:bidform ATTR=NAME:bid_* CONTENT=YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:Save
}
[b]ELSE[/b]
SKIP
Ideas how I might solve this lovely problem :!:

Thanks!

P.S

I am looking for a contractor to help me write a few simple scripts for me to help solve some basic problems if you are interested contact me
automate.scripts at mioglobal.com $$$
Hannes, Tech Support

Re: IF Else statements in Imacros

Post by Hannes, Tech Support » Thu Nov 10, 2011 10:48 am

There are no conditionals in plain macros.

You will need to use some script, cf. http://wiki.imacros.net/Firefox#Javascr ... _Interface
anyoneyoubet
Posts: 4
Joined: Fri Nov 11, 2011 12:16 am

Re: IF Else statements in Imacros

Post by anyoneyoubet » Fri Nov 11, 2011 11:45 am

Note: this is for the free imacros edition code.

rename the iim to end in js.

my-micro.js
-------------------------------
your code

Code: Select all

TAB T=1
URL GOTO=https://www.shopatron.com/mfg/orders/assigned_orders
IF { TAG POS=1 TYPE=STRONG ATTR=TXT:Groupon* }
THEN {
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:assign_ship_* ATTR=NAME:return_btn_*
TAG POS=1 TYPE=SELECT FORM=NAME:bidform ATTR=NAME:mfg_loc CONTENT=%46
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:bidform ATTR=NAME:bid_* CONTENT=YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:Save
}
[b]ELSE[/b]
SKIP
new code

Code: Select all

iimPlay("CODE:TAB T=1\nURL GOTO=https://www.shopatron.com/mfg/orders/assigned_orders\nTAG POS=1 TYPE=STRONG ATTR=TXT:Groupon* EXTRACT=TXT");
var G_Extract= iimGetLastExtract(1);
if (G_Extract=="Groupon*")
{
var G_Extract="CODE:";
G_Extract=G_Extract+"TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:assign_ship_* ATTR=NAME:return_btn_*\n");
G_Extract=G_Extract+TAG POS=1 TYPE=SELECT FORM=NAME:bidform ATTR=NAME:mfg_loc CONTENT=%46\n");
G_Extract=G_Extract+TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:bidform ATTR=NAME:bid_* CONTENT=YES\n");
G_Extract=G_Extract+TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:Save\n");
iimPlay(G_Extract)
}
you will not need the skip unless you want to TAG the word SKIP

then just add the line you need to tag the word skip

Code: Select all


else if(G_Extract!="Groupon")
{
iimPlay("CODE:TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:SKIP\n")
} 
Hannes, Tech Support

Re: IF Else statements in Imacros

Post by Hannes, Tech Support » Mon Nov 14, 2011 10:34 am

Thanks for taking your time and for sharing your solution!
TimFrazer
Posts: 3
Joined: Tue Nov 08, 2011 6:12 pm

Re: IF Else statements in Imacros

Post by TimFrazer » Mon Nov 14, 2011 5:09 pm

Thank you so much for your help!
I'll try using this baby today.

Cheers,
TimFrazer
Posts: 3
Joined: Tue Nov 08, 2011 6:12 pm

Re: IF Else statements in Imacros

Post by TimFrazer » Mon Nov 14, 2011 7:19 pm

Hey Guys,
I tried the code but I keep on getting error 991. I fixed a couple of syntax erros from the original, but it still won't 'play'.
Any ideas what I'm missing? I'm using Imacros for Firefox.

Code: Select all

iimPlay("CODE:TAB T=1\nURL GOTO=https://www.shopatron.com/mfg/orders/assigned_orders\nTAG POS=1 TYPE=STRONG ATTR=TXT:Groupon* EXTRACT=TXT");

var G_Extract=iimGetLastExtract(1);

if (G_Extract=="Groupon*") {
var G_Extract="CODE:";
G_Extract=G_Extract+"TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:assign_ship_* ATTR=NAME:return_btn_*\n");
G_Extract=G_Extract+"TAG POS=1 TYPE=SELECT FORM=NAME:bidform ATTR=NAME:mfg_loc CONTENT=%46\n");
G_Extract=G_Extract+"TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:bidform ATTR=NAME:bid_* CONTENT=YES\n");
G_Extract=G_Extract+"TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:Save\n");
iimPlay(G_Extract);
}
pakkna
Posts: 1
Joined: Tue Jan 26, 2016 4:22 pm

Re: IF Else statements in Imacros

Post by pakkna » Tue Jan 26, 2016 4:29 pm

Please, solve this iMacoss code , I Could not run it,

VERSION BUILD=8961227 RECORDER=FX
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 600
SET MSSN http://forum.imacros.net

ADD !EXTRACT {{!URLCURRENT}}
if ( {{!EXTRACT}} == {{MSSN}} )
{
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:OnlineForm ATTR=ID:btn1
}
Hijotech
Posts: 14
Joined: Tue Sep 26, 2017 5:54 pm

Re: IF Else statements in Imacros

Post by Hijotech » Fri Oct 06, 2017 12:38 am

anyoneyoubet wrote:Note: this is for the free imacros edition code.

rename the iim to end in js.

my-micro.js
-------------------------------
your code

Code: Select all

TAB T=1
URL GOTO=https://www.shopatron.com/mfg/orders/assigned_orders
IF { TAG POS=1 TYPE=STRONG ATTR=TXT:Groupon* }
THEN {
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:assign_ship_* ATTR=NAME:return_btn_*
TAG POS=1 TYPE=SELECT FORM=NAME:bidform ATTR=NAME:mfg_loc CONTENT=%46
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:bidform ATTR=NAME:bid_* CONTENT=YES
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:Save
}
[b]ELSE[/b]
SKIP
new code

Code: Select all

iimPlay("CODE:TAB T=1\nURL GOTO=https://www.shopatron.com/mfg/orders/assigned_orders\nTAG POS=1 TYPE=STRONG ATTR=TXT:Groupon* EXTRACT=TXT");
var G_Extract= iimGetLastExtract(1);
if (G_Extract=="Groupon*")
{
var G_Extract="CODE:";
G_Extract=G_Extract+"TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:assign_ship_* ATTR=NAME:return_btn_*\n");
G_Extract=G_Extract+TAG POS=1 TYPE=SELECT FORM=NAME:bidform ATTR=NAME:mfg_loc CONTENT=%46\n");
G_Extract=G_Extract+TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:bidform ATTR=NAME:bid_* CONTENT=YES\n");
G_Extract=G_Extract+TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:Save\n");
iimPlay(G_Extract)
}
you will not need the skip unless you want to TAG the word SKIP

then just add the line you need to tag the word skip

Code: Select all


else if(G_Extract!="Groupon")
{
iimPlay("CODE:TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:bidform ATTR=NAME:submit_button&&VALUE:SKIP\n")
} 


Hi,


My request is similiar that of the post here. I want imacros on chrome to place bet automatically with a line of code on .iim if the home team odds is greater than >2.90 it will place a bet on home to win, draw, away team to win with under 2.5 and over 2.5 and if the home team odds is less than <2.90 it will skip the bet it auth to bet to the next line of code. here is the code on how i want it work:

IF { TAG POS=1 TYPE=LABEL ATTR=TXT:>2.90* }

THEN {
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:Match_Result_0_Home CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:Match_Result_0_Draw CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

TAG POS=1 TYPE=SELECT ATTR=ID:bet-select-market CONTENT=%1x2Scores_Over_Under_2_5_UNDER2
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:1x2Scores_Over_Under_2_5_0__1x2AwayScoresUnder2 CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

TAG POS=1 TYPE=SELECT ATTR=ID:bet-select-market CONTENT=%HomeAwayScores_Over_Under_2_5_AWAY2
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:HomeAwayScores_Over_Under_2_5_0_AwayScoresOver2 CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket
Wait Seconds=120
}


ELSE {

TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:Match_Result_0_Away CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:Match_Result_0_Draw CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

TAG POS=1 TYPE=SELECT ATTR=ID:bet-select-market CONTENT=%1x2Scores_Over_Under_2_5_UNDER2
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:1x2Scores_Over_Under_2_5_0__1x2HomeScoresUnder2 CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

TAG POS=1 TYPE=SELECT ATTR=ID:bet-select-market CONTENT=%HomeAwayScores_Over_Under_2_5
TAG POS=1 TYPE=INPUT:CHECKBOX ATTR=ID:HomeAwayScores_Over_Under_2_5_0_HomeScoresOver2 CONTENT=YES
TAG POS=1 TYPE=INPUT:NUMBER ATTR=ID:inputAmount CONTENT=100
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet
TAG POS=1 TYPE=BUTTON ATTR=ID:button_bet_ticket

Wait Seconds=120

}



PLEASE JUST GIVE ME THE CORRECT CODE OF THIS.


Thanks
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: IF Else statements in Imacros

Post by chivracq » Fri Oct 06, 2017 3:46 am

Hannes, Tech Support wrote:There are no conditionals in plain macros.

You will need to use some script, cf. http://wiki.imacros.net/Firefox#Javascr ... _Interface
Oops...!
- Workarounds for Conditional Logic in Macro Code

But hum, Post from @Hannes was from 2011, maybe 'EVAL()' had not been implemented then yet, I started to do some "heavy" Conditional Logic in '.iim' once 'EVAL()' was introduced...

Even if, yep..., '.js' Scripts are still the "Norm" and "Standard", but until 2 years ago, I think I was the only one for several years using Conditional Logic in pure '.iim', but since 2 years, I really notice a Trend-Change, I would say 30%-70% now...? Maybe because I'm quite Active on the Forum and I practically only provide Solutions in pure '.iim', so I guess more Users have adopted pure '.iim' Scripts...

This is my "little way of changing the World", I guess, ah-ah...!! 8)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Hijotech
Posts: 14
Joined: Tue Sep 26, 2017 5:54 pm

Re: IF Else statements in Imacros

Post by Hijotech » Fri Oct 06, 2017 6:48 am

chivracq wrote:
Hannes, Tech Support wrote:There are no conditionals in plain macros.

You will need to use some script, cf. http://wiki.imacros.net/Firefox#Javascr ... _Interface
Oops...!
- Workarounds for Conditional Logic in Macro Code

But hum, Post from @Hannes was from 2011, maybe 'EVAL()' had not been implemented then yet, I started to do some "heavy" Conditional Logic in '.iim' once 'EVAL()' was introduced...

Even if, yep..., '.js' Scripts are still the "Norm" and "Standard", but until 2 years ago, I think I was the only one for several years using Conditional Logic in pure '.iim', but since 2 years, I really notice a Trend-Change, I would say 30%-70% now...? Maybe because I'm quite Active on the Forum and I practically only provide Solutions in pure '.iim', so I guess more Users have adopted pure '.iim' Scripts...

This is my "little way of changing the World", I guess, ah-ah...!! 8)
Yap can you help with the Conditional Logic in '.iim script on my above codes to work the way i want it.
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: IF Else statements in Imacros

Post by chivracq » Fri Oct 06, 2017 8:06 pm

Hijotech wrote:Yap can you help with the Conditional Logic in '.iim script on my above codes to work the way i want it.
Yeah, but no sorry, I'm not really too motivated to help you on this one as I don't help for Games/Votes/Betting and I few other "Areas"..., and you still don't use the Forum "correctly", I gave you already some "Artistic" "Explanation" (I hope you like the Colours, ah-ah...! 8) ) in your own Thread....
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
titus00
Posts: 1
Joined: Sat Dec 02, 2017 5:30 am

if else execute

Post by titus00 » Sat Dec 02, 2017 5:53 am

Hi All,

I am trying to write an if else script in imacros that will read a constant changing of numbers which if increase or decrease by a certain percentage then execute the command or else do not execute or skip the command. this may be simple to some but not to me as i am a beginner with if else statements. please help and thanks in advance.
chivracq
Posts: 7718
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: if else execute

Post by chivracq » Sat Dec 02, 2017 7:19 am

titus00 wrote:Hi All,

I am trying to write an if else script in imacros that will read a constant changing of numbers which if increase or decrease by a certain percentage then execute the command or else do not execute or skip the command. this may be simple to some but not to me as i am a beginner with if else statements. please help and thanks in advance.
(Approved because no Spam but (disappointing) Low Quality Post... => Read my further Comments for me to read (and maybe answer) your Post...)
=> CIM...! :mrgreen: (Pfff, and read my Sig for the "rest"...!)
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Post Reply