Error for current loop

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Error for current loop

Post by Aditya93 » Sat Nov 25, 2017 6:21 am

Hi

I wanted to know is it possible to skip the current code and move on with the loop if any error is encountered.

Code: Select all

VERSION BUILD=10022823
SET !TIMEOUT_STEP 2
SET !DATASOURCE Dragon_List.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES

DS CMD=CLICK X=319 Y=19 CONTENT={TAB} 
DS CMD=CLICK X=319 Y=19 CONTENT={{!COL1}}
DS CMD=CLICK X=364 Y=9 CONTENT={TAB} 
DS CMD=CLICK X=364 Y=9 CONTENT={{!COL2}}
DS CMD=CLICK X=364 Y=9 CONTENT={ENTER}

DS CMD=MOVETO X=421 Y=428 CONTENT=		

WAIT SECONDS=3

DS CMD=CLICK X=421 Y=429 CONTENT=		

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95
DS CMD=MOVETO X=514 Y=461 CONTENT=		
WAIT SECONDS=2

DS CMD=CLICK X={{!IMAGEX}} Y={{!IMAGEY}} CONTENT=
DS CMD=CLICK X=421 Y=428 CONTENT=						
DS CMD=CLICK X=389 Y=389 CONTENT=
DS CMD=CLICK X=504 Y=560 CONTENT=				
WAIT SECONDS=3
DS CMD=CLICK X=455 Y=538 CONTENT=
DS CMD=CLICK X=550 Y=269 CONTENT=
DS CMD=CLICK X=301 Y=650 CONTENT=
DS CMD=CLICK X=553 Y=262 CONTENT=
DS CMD=CLICK X=302 Y=646 CONTENT=
DS CMD=CLICK X=550 Y=241 CONTENT=
DS CMD=CLICK X=298 Y=650 CONTENT=
DS CMD=CLICK X=550 Y=241 CONTENT=
DS CMD=CLICK X=298 Y=653 CONTENT=
DS CMD=CLICK X=448 Y=433 CONTENT=
DS CMD=CLICK X=606 Y=405 CONTENT=
DS CMD=CLICK X=603 Y=405 CONTENT=
DS CMD=CLICK X=606 Y=405 CONTENT=
DS CMD=CLICK X=410 Y=405 CONTENT=
DS CMD=KEY CONTENT=21{ENTER}
DS CMD=CLICK X=725 Y=723 CONTENT=
WAIT SECONDS=3
DS CMD=CLICK X=231 Y=433 CONTENT=
DS CMD=CLICK X=452 Y=520 CONTENT=
DS CMD=CLICK X=452 Y=636 CONTENT=
DS CMD=CLICK X=550 Y=643 CONTENT=

i had to SET !ERRORIGNORE YES, otherwise the loop totally ends, but i want it to just skip the current run and move on with the iteration.



Deatils
VERSION BUILD=10022823
Windows 7 x64 (English)
Imacro Browser V10.0.2.2823
Included Demo macro works
URL - https://empire.goodgamestudios.com/

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

Re: Error for current loop

Post by chivracq » Sat Nov 25, 2017 4:02 pm

Aditya93 wrote:Hi

I wanted to know is it possible to skip the current code and move on with the loop if any error is encountered.

Code: Select all

VERSION BUILD=10022823
SET !TIMEOUT_STEP 2
SET !DATASOURCE Dragon_List.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES

DS CMD=CLICK X=319 Y=19 CONTENT={TAB} 
DS CMD=CLICK X=319 Y=19 CONTENT={{!COL1}}
DS CMD=CLICK X=364 Y=9 CONTENT={TAB} 
DS CMD=CLICK X=364 Y=9 CONTENT={{!COL2}}
DS CMD=CLICK X=364 Y=9 CONTENT={ENTER}

DS CMD=MOVETO X=421 Y=428 CONTENT=		

WAIT SECONDS=3

DS CMD=CLICK X=421 Y=429 CONTENT=		

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95
DS CMD=MOVETO X=514 Y=461 CONTENT=		
WAIT SECONDS=2

DS CMD=CLICK X={{!IMAGEX}} Y={{!IMAGEY}} CONTENT=
DS CMD=CLICK X=421 Y=428 CONTENT=						
DS CMD=CLICK X=389 Y=389 CONTENT=
DS CMD=CLICK X=504 Y=560 CONTENT=				
WAIT SECONDS=3
DS CMD=CLICK X=455 Y=538 CONTENT=
DS CMD=CLICK X=550 Y=269 CONTENT=
DS CMD=CLICK X=301 Y=650 CONTENT=
DS CMD=CLICK X=553 Y=262 CONTENT=
DS CMD=CLICK X=302 Y=646 CONTENT=
DS CMD=CLICK X=550 Y=241 CONTENT=
DS CMD=CLICK X=298 Y=650 CONTENT=
DS CMD=CLICK X=550 Y=241 CONTENT=
DS CMD=CLICK X=298 Y=653 CONTENT=
DS CMD=CLICK X=448 Y=433 CONTENT=
DS CMD=CLICK X=606 Y=405 CONTENT=
DS CMD=CLICK X=603 Y=405 CONTENT=
DS CMD=CLICK X=606 Y=405 CONTENT=
DS CMD=CLICK X=410 Y=405 CONTENT=
DS CMD=KEY CONTENT=21{ENTER}
DS CMD=CLICK X=725 Y=723 CONTENT=
WAIT SECONDS=3
DS CMD=CLICK X=231 Y=433 CONTENT=
DS CMD=CLICK X=452 Y=520 CONTENT=
DS CMD=CLICK X=452 Y=636 CONTENT=
DS CMD=CLICK X=550 Y=643 CONTENT=
i had to SET !ERRORIGNORE YES, otherwise the loop totally ends, but i want it to just skip the current run and move on with the iteration.

Deatils

Code: Select all

VERSION BUILD=10022823
Windows 7 x64 (English)
Imacro Browser V10.0.2.2823
Included Demo macro works
URL - https://empire.goodgamestudios.com/

Thanks
Beh..., yep, using '!ERRORIGNORE' and a shortened '!TIMEOUT_STEP' like you already do is the way to go, I would think...
Hum..., Flash Game I see, which explains your Use of the 'DS' Mode, OK...

But yep, if an Error occurs, '!ERRORIGNORE' should indeed keep your Script running and finish that Run, and then it should start the next Run with '!LOOP' +1...
The only Explanation I can think of if your Script then stops completely is if '!LOOP' has reached the End of your DataSource or if you have 2 consecutive empty Rows in your '.CSV'...

Some "strange" Behaviour I've noticed sometimes, is on "heavy" Pages with "a lot of" JavaScript Buttons (or Links) forcing an Update or a Refresh of the Page, sometimes if such a Refresh didn't completely refresh and fully re-load the Page, the Script then seems to "slide" on the Page and won't be able to click on any Button anymore as the JavaScript behind the Buttons probably didn't load correctly... The Buttons are there on the Page and iMacros finds them, but a Click on them, from a 'TAG' Statement or even a manual Click won't do anything anymore... A manual Refresh of the Page is then the only way to get the Script working again... Maybe the same thing happens with your Flash Object and the Code behind it...? :oops:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Sun Nov 26, 2017 1:48 am

So, is there any way such that i can use if else in imacro for image validation via EVAL to check if

Code: Select all

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95 
has been clicked and then only the below commands are run otherwise they wont and move on with the loop.

As this is in flash i dont have the TAG and other things to check upon
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error for current loop

Post by chivracq » Sun Nov 26, 2017 2:56 am

Aditya93 wrote:So, is there any way such that i can use if else in imacro for image validation via EVAL to check if

Code: Select all

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95 
has been clicked and then only the below commands are run otherwise they wont and move on with the loop.

As this is in flash i dont have the TAG and other things to check upon
I've never used iMB (I only use the Free iMacros for FF Add-on myself) and therefore the 'DS' Mode, but yep, I would think, simply run a Check on '!IMAGEX' and/or '!IMAGEY' that hold(s) the Coordinate(s) of your 'attack_button.png', like this later Statement of yours is already Conditional:

Code: Select all

DS CMD=CLICK X={{!IMAGEX}} Y={{!IMAGEY}} CONTENT=
I guess if the Button was not found with the 'IMAGECLICK' Statement, then the later 'CLICK' Statement does nothing if the 2 Coordinates are "=0" or 'NULL' (I don't know what the Original/Default Value is if the Image is not found...).

If you don't want the 'MOVETO' and all 'CLICK' Statements with hard-coded X/Y Coordinates after the 'IMAGECLICK' to be "fired", you can for each Statement compute those Coordinates one by one using 'EVAL()'.

Or if when your 'attack_button' is found, if it is always located at the same Place on the Page, and therefore its '!IMAGEX/Y' Coordinates are always the same, you could even more simply use 'ADD' (for a Subtraction) to compute the exact X/Y Values you need for each 'CLICK' Statement or that you get some Negative Value if the Button was not found if the Default Value is "=0" or you will get some "weird" String in the form "_undefined_-218" or "NULL-218" (hum, if those "weird" Strings do not trigger some Compile Error, but I don't think so as they will be computed Vars) with which the 'CLICK' Statements won't do anything...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Mon Nov 27, 2017 1:47 am

tried EVAL() but didn't work as i had hoped

Code: Select all

SET !TIMEOUT_STEP 2
SET !DATASOURCE Dragon_List.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES

DS CMD=CLICK X=319 Y=19 CONTENT={TAB} 
DS CMD=CLICK X=319 Y=19 CONTENT={{!COL1}}
DS CMD=CLICK X=364 Y=9 CONTENT={TAB} 
DS CMD=CLICK X=364 Y=9 CONTENT={{!COL2}}
DS CMD=CLICK X=364 Y=9 CONTENT={ENTER}

DS CMD=MOVETO X=421 Y=428 CONTENT=		

WAIT SECONDS=3

DS CMD=CLICK X=421 Y=429 CONTENT=		

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95
EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=})
this statement gives an error: Can not parse macro line

Code: Select all

EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=})
could you tell me how to place the condition in EVAL() and how to add the state which is to be executed if the condition is true or when its false
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error for current loop

Post by chivracq » Mon Nov 27, 2017 1:57 am

Aditya93 wrote:tried EVAL() but didn't work as i had hoped

Code: Select all

SET !TIMEOUT_STEP 2
SET !DATASOURCE Dragon_List.csv
SET !DATASOURCE_COLUMNS 2
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !ERRORIGNORE YES

DS CMD=CLICK X=319 Y=19 CONTENT={TAB} 
DS CMD=CLICK X=319 Y=19 CONTENT={{!COL1}}
DS CMD=CLICK X=364 Y=9 CONTENT={TAB} 
DS CMD=CLICK X=364 Y=9 CONTENT={{!COL2}}
DS CMD=CLICK X=364 Y=9 CONTENT={ENTER}

DS CMD=MOVETO X=421 Y=428 CONTENT=		

WAIT SECONDS=3

DS CMD=CLICK X=421 Y=429 CONTENT=		

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95
EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=})
this statement gives an error: Can not parse macro line

Code: Select all

EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=})
could you tell me how to place the condition in EVAL() and how to add the state which is to be executed if the condition is true or when its false
Yeah, but check a bit the Wiki for the Syntax to use for the iMacros 'EVAL()' Command... Or search the Forum which contains Hundreds of Examples... You cannot "create" your own Syntax and hope that it will work, ah-ah...!, nice Try...! 8)
'EVAL()' allows you to compute a Value for a Var and you will reuse that Var in some 'TAG' or 'CLICK' Statement for the Coordinates for example in your Case...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Mon Nov 27, 2017 5:23 am

I had tried multiple times to get the correct syntax before posting here, but non of the examples shown in wiki are of image validation through EVAl()
some hit and trials that i made

509 = the X coordinate of the place where the image will get clicked if its there.

Code: Select all

SET !VAR2 = {{!IMAGEX}}
SET !VAR1 EVAL( IF(VAR2 == "509"))

Code: Select all

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95 CONTENT = EVAL( IF(VAR2 == "509"))

Code: Select all

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95 CONTENT = EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=}))

All of the above resulted in wrong format or incorrect syntax :roll: :x
a little hint in the syntax through which i can use :oops:

if(image clicked == TRUE)
{click X and Y
click X1 and Y1....}
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error for current loop

Post by chivracq » Mon Nov 27, 2017 6:53 am

Aditya93 wrote:I had tried multiple times to get the correct syntax before posting here, but non of the examples shown in wiki are of image validation through EVAl()
some hit and trials that i made

509 = the X coordinate of the place where the image will get clicked if its there.

Code: Select all

SET !VAR2 = {{!IMAGEX}}
SET !VAR1 EVAL( IF(VAR2 == "509"))

Code: Select all

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95 CONTENT = EVAL( IF(VAR2 == "509"))

Code: Select all

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95 CONTENT = EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=}))
All of the above resulted in wrong format or incorrect syntax :roll: :x
a little hint in the syntax through which i can use :oops:

if(image clicked == TRUE)
{click X and Y
click X1 and Y1....}
Yeah, not complicated to have a look at the Wiki or find any of the 100's Examples on the Forum..., even if the Examples in the Wiki are already nearly too complicated for what you want... :roll:

So, OK, applied to your one Statement with your "kinky" Syntax in your previous Post:

Code: Select all

EVAL( IF({{!IMAGEX}} == "421"){DS CMD=CLICK X=629 Y=256 CONTENT=})
=> ... That would give:

Code: Select all

SET Coord_X_1 EVAL("var ix='{{!IMAGEX}}'; var x; if(ix=='421'){x=629;} else{x=0;}; x;")
SET Coord_Y_1 EVAL("var ix='{{!IMAGEX}}'; var y; if(ix=='421'){y=256;} else{y=0;}; y;")
DS CMD=CLICK X={{Coord_X_1}} Y={{Coord_Y_1}} CONTENT=
And you do the same for all 'CLICK' Statements that you want to make Conditional...
The Single Quotes around the "421" are probably not needed..., but you can use 'PROMPT' to debug your Script and follow your Vars...
And you might need to use '!ERRORIGNORE', if you were not using it already, for the "CLICK X=0 Y=0" Cases...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Mon Nov 27, 2017 9:02 am

Thank you!!!
Worked like a charm
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error for current loop

Post by chivracq » Mon Nov 27, 2017 9:20 am

Aditya93 wrote:Thank you!!!
Worked like a charm
Yep, you're welcome... :wink:
(And you got a bit "lucky" btw..., I usually don't help for Games normally..., so..., enjoy...! 8) )
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Tue Nov 28, 2017 1:57 am

chivracq wrote:
Aditya93 wrote:Thank you!!!
Worked like a charm
Yep, you're welcome... :wink:
(And you got a bit "lucky" btw..., I usually don't help for Games normally..., so..., enjoy...! 8) )
Wanted to know one more thing, can nested "if" be used in a similar manner in this?
and one more thing can text be extracted from flash, as it doesn't get recognized in the extract text option. :)

something that i tried

Code: Select all

WAIT SECONDS=1

DS CMD=CLICK X=417 Y=441 CONTENT=		

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95
WAIT SECONDS=1

IMAGECLICK POS=1 IMAGE=green_tick.png CONFIDENCE=95
WAIT SECONDS=1

IMAGESEARCH POS=1 IMAGE=spearwoman_check.png CONFIDENCE=95
'PROMPT {{!IMAGEX}}

SET Coord_X_1 EVAL("var ix='{{!IMAGEX}}'; var x; if(ix=='548'){"IMAGESEARCH POS=1 IMAGE=Extra_comm.png CONFIDENCE=95"; if(ix=='-1'){x='138'}} else{x=0;}; x;")
SET Coord_Y_1 EVAL("var ix='{{!IMAGEX}}'; var y; if(ix=='548'){"IMAGESEARCH POS=1 IMAGE=Extra_comm.png CONFIDENCE=95"; if(ix=='-1'){y='401'}} else{y=0;}; y;")
DS CMD=CLICK X={{Coord_X_1}} Y={{Coord_Y_1}} CONTENT=
'DS CMD=CLICK X=138 Y=401 CONTENT=

SET Coord_X_1 EVAL("var ix='{{!IMAGEX}}'; var x; if(ix=='-1'){x=393;} else{x=0;}; x;")
SET Coord_Y_1 EVAL("var ix='{{!IMAGEX}}'; var y; if(ix=='-1'){y=240;} else{y=0;}; y;")
DS CMD=CLICK X={{Coord_X_1}} Y={{Coord_Y_1}} CONTENT=
'DS CMD=CLICK X=393 Y=240 CONTENT=

DS CMD=KEY CONTENT=6{ENTER}
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Error for current loop

Post by chivracq » Tue Nov 28, 2017 3:01 am

Aditya93 wrote:Wanted to know one more thing, can nested "if" be used in a similar manner in this?
and one more thing can text be extracted from flash, as it doesn't get recognized in the extract text option. :)
1- Nested "if":
Not sure what you mean exactly by "Nested if" as your Qt is a bit vague..., but yep, you can use it for "Nested Loops" for example, and you can find several Threads on the Forum about "Nested Loop(s)" in pure '.iim' using 'EVAL()'.
But you could mean an "if" within an "if", then yep, simply use the '&' Operator to combine 2 "if"'s in a same 'EVAL()' Statement..., and you can have as many 'if/else' Conditions as you want in one same 'EVAL()' Statement...
(I've got one with 144 'if/else' Conditions in one of my own Scripts, ah-ah...!, even if I now would know how to shorten if drastically using a Combination of other JS Functions, but I had made it about 5 years ago when I had started using "my" 'EVAL()' Method, so I hardly knew anything about JavaScript at that time, and it still works perfectly, so I never bothered (and never needed...!) to re-implement it differently/more efficiently...)

2- Extract Text from Flash:
Well, yes and no, or rather NO but maybe yes, but it can be tricky...
- There is indeed no 'TAG' Mode on Flash Objects, then you can't use the 'EXTRACT' Command...

- I have a Workaround or rather an "Alternative" for the 'EXTRACT' Mechanism using the 'EVENT' Mode in some tricky Situations that might work on Flash Objects but I have never really posted it yet on the Forum, only mentioned more or less precisely in a few Threads as one of the several Options, and I have never tested it on Flash Objects but I guess it would work even if I think it might be a bit tricky...
But you are on iMB v10.x and the 'EVENT' Mode only got implemented in iMB from iMB v11.0.

- I have another Method that I use myself using the 'TAG' Mode, never posted either, and I don't think I will post it either as I use it for a Game as well, oops...! But in my "Case", the Site I use that Method on has relatively "small" Flash Objects embedded on the Page with Properties/Vars passed from the HTML/PHP Page to the Flash Object, and that are accessible from the HTML Page (using 'EXTRACT=HTM' on the Flash Container), but I'm not sure that would work for your Game which looks completely in Flash to me, so I guess once you've loaded your Game, you are completely in a Flash Environment and I would think that Method won't be able to access anything that is purely "inside" the Flash Object.

But those 2 Methods are a bit tricky and a bit "Advanced" Level, and you had to struggle a bit too long already I would think for some fairly simple 'EVAL()' Statement with a very simple 'if/else' Condition, so I'm afraid that will be a bit too "High Level" for you, and as I mentioned in my last Post, I normally don't (really) want to help (too precisely) for Games..., even if I gained myself absolutely all my Knowledge about iMacros from playing Games as well, re-oops...! :oops:
But OK, we'll see about that, if you understand a bit what I meant with "the 2 Methods" and understand how to (start to) implement them or one of them, then maybe I'll help you a bit further, ah-ah...! :wink:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Tue Nov 28, 2017 3:23 am

1- Nested "if":
Not sure what you mean exactly by "Nested if" as your Qt is a bit vague..., but yep, you can use it for "Nested Loops" for example, and you can find several Threads on the Forum about "Nested Loop(s)" in pure '.iim' using 'EVAL()'.
But you could mean an "if" within an "if", then yep, simply use the '&' Operator to combine 2 "if"'s in a same 'EVAL()' Statement..., and you can have as many 'if/else' Conditions as you want in one same 'EVAL()' Statement...
(I've got one with 144 'if/else' Conditions in one of my own Scripts, ah-ah...!, even if I now would know how to shorten if drastically using a Combination of other JS Functions, but I had made it about 5 years ago when I had started using "my" 'EVAL()' Method, so I hardly knew anything about JavaScript at that time, and it still works perfectly, so I never bothered (and never needed...!) to re-implement it differently/more efficiently...)
What i tried

Code: Select all

DS CMD=CLICK X=417 Y=441 CONTENT=		

IMAGECLICK POS=1 IMAGE=attack_button.png CONFIDENCE=95
WAIT SECONDS=1

IMAGECLICK POS=1 IMAGE=green_tick.png CONFIDENCE=95
WAIT SECONDS=1

IMAGESEARCH POS=1 IMAGE=spearwoman_check.png CONFIDENCE=95
'PROMPT {{!IMAGEX}}
SET var ix={{!IMAGEX}}
PROMPT {{!IMAGEX}}
PROMPT {{ix}}

IMAGESEARCH POS=1 IMAGE=Extra_comm.png CONFIDENCE=95
SET var ix1='{{!IMAGEX}}'
PROMPT {{!IMAGEX}}
PROMPT {{ix1}}

SET Coord_X_1 EVAL("var x; if(ix=='548' AND ix1=='-1'){x=138;} else{x=0;}; x;")
SET Coord_Y_1 EVAL("var y; if(ix=='548' AND ix1=='-1'){y=401;} else{y=0;}; y;")
DS CMD=CLICK X={{Coord_X_1}} Y={{Coord_Y_1}} CONTENT=
'DS CMD=CLICK X=138 Y=401 CONTENT=

SET Coord_X_1 EVAL("var ix='{{!IMAGEX}}'; var x; if(ix=='-1'){x=393;} else{x=0;}; x;")
SET Coord_Y_1 EVAL("var ix='{{!IMAGEX}}'; var y; if(ix=='-1'){y=240;} else{y=0;}; y;")
DS CMD=CLICK X={{Coord_X_1}} Y={{Coord_Y_1}} CONTENT=
'DS CMD=CLICK X=393 Y=240 CONTENT=

DS CMD=KEY CONTENT=6{ENTER}

didn't get any value in ix or ix1 even though IMAGEX is giving me the intended value

Code: Select all

IMAGESEARCH POS=1 IMAGE=Extra_comm.png CONFIDENCE=95
SET var ix1='{{!IMAGEX}}'
PROMPT {{!IMAGEX}}
PROMPT {{ix1}}


i guess the AND implementation is correct

Code: Select all

SET Coord_X_1 EVAL("var x; if(ix=='548' AND ix1=='-1'){x=138;} else{x=0;}; x;")
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Tue Nov 28, 2017 9:39 am

When i try to run the code directly it works fine, but when i run it through a scheduler the conditional statements doesn't work and no clicks are done
Any suggestions
Aditya93
Posts: 55
Joined: Sat Nov 25, 2017 5:34 am

Re: Error for current loop

Post by Aditya93 » Thu Dec 07, 2017 2:37 am

2- Extract Text from Flash:
Well, yes and no, or rather NO but maybe yes, but it can be tricky...
- There is indeed no 'TAG' Mode on Flash Objects, then you can't use the 'EXTRACT' Command...

- I have a Workaround or rather an "Alternative" for the 'EXTRACT' Mechanism using the 'EVENT' Mode in some tricky Situations that might work on Flash Objects but I have never really posted it yet on the Forum, only mentioned more or less precisely in a few Threads as one of the several Options, and I have never tested it on Flash Objects but I guess it would work even if I think it might be a bit tricky...
But you are on iMB v10.x and the 'EVENT' Mode only got implemented in iMB from iMB v11.0.

- I have another Method that I use myself using the 'TAG' Mode, never posted either, and I don't think I will post it either as I use it for a Game as well, oops...! But in my "Case", the Site I use that Method on has relatively "small" Flash Objects embedded on the Page with Properties/Vars passed from the HTML/PHP Page to the Flash Object, and that are accessible from the HTML Page (using 'EXTRACT=HTM' on the Flash Container), but I'm not sure that would work for your Game which looks completely in Flash to me, so I guess once you've loaded your Game, you are completely in a Flash Environment and I would think that Method won't be able to access anything that is purely "inside" the Flash Object.

But those 2 Methods are a bit tricky and a bit "Advanced" Level, and you had to struggle a bit too long already I would think for some fairly simple 'EVAL()' Statement with a very simple 'if/else' Condition, so I'm afraid that will be a bit too "High Level" for you, and as I mentioned in my last Post, I normally don't (really) want to help (too precisely) for Games..., even if I gained myself absolutely all my Knowledge about iMacros from playing Games as well, re-oops...! :oops:
But OK, we'll see about that, if you understand a bit what I meant with "the 2 Methods" and understand how to (start to) implement them or one of them, then maybe I'll help you a bit further, ah-ah...! :wink:
I tried and searched a lot also about this, but for the 1st method, i couldn't get imacro vr 11+, so unable to test it out
for the 2nd method, i wast able to find any 'TAG' in flash, even normal other websites the extracting was working correctly.
but in flash couldn't find any object

Hope you will reply @Chivracq
Post Reply