New to IMacro, looping and stopping script when captcha come

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
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

New to IMacro, looping and stopping script when captcha come

Post by bestisme » Sun Mar 23, 2014 7:49 am

Hi, I am new to IMacros, and I think it is really great!

I have no experience with scripts, and I found the current script hard for me :(

So, I recorded my actions in an MMORPG-

Code: Select all

VERSION BUILD=8810214 RECORDER=FX
TAB T=1
URL GOTO=http://pokemoncreed.net/battle.php?opp=Mysterious%20Trainer
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=947 ATTR=NAME:move
TAG POS=1 TYPE=A ATTR=TXT:Golurk
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=9352 ATTR=NAME:move
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=8416 ATTR=NAME:move
TAG POS=1 TYPE=A ATTR=TXT:Golurk
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=11051 ATTR=NAME:move
TAG POS=2 TYPE=A ATTR=TXT:Golurk
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=14729 ATTR=NAME:move
TAG POS=3 TYPE=SPAN ATTR=TXT:a
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=6954 ATTR=NAME:move
TAG POS=1 TYPE=A ATTR=TXT:Rotom
TAG POS=2 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=43068 ATTR=NAME:move
TAG POS=1 TYPE=BUTTON ATTR=TXT:Restart<SP>Battle
Now, I want to add a Loop, so that the script repeats everything again. But the problem is, I don't see any option in recorder to do that
So, how do I add that?


The second thing is, I want to know, can I minimize the firefox window use Photoshop while the macro will continue?


The third thing is, when playing the MMORPG game, sometimes a captcha appears. The link doesn't change, just the content on screen changes. And If it clicks the buttons while the captcha is on screen, I will get banned. So, is there a way, so after every action, it checks if captcha is there, and if its there, it stops automatically and displays a message box, so I can manually fill captcha and then run the script again?

For detecting if captcha is there, I have the following idea -
When captcha appears, there comes a heading "Verification Code". So perhaps, I can take a screenshot of it, and then have it detect if that screenshot is present on the screen or not, if image is there, the script will stop, and if image is not there, then script will go on.


Please help me
And, I don't know anything about scripts, so please explain me about the script :D
fastviper
Posts: 46
Joined: Tue Mar 15, 2011 1:30 pm

Re: New to IMacro, looping and stopping script when captcha

Post by fastviper » Mon Mar 24, 2014 2:28 pm

Now, I want to add a Loop, so that the script repeats everything again. But the problem is, I don't see any option in recorder to do that
So, how do I add that?
Play the same script several times. The {{!LOOP}} is a value of current loop sequence.
The second thing is, I want to know, can I minimize the firefox window use Photoshop while the macro will continue?
Unless you use EVENT features of iMacros - probably yes.
The third thing is, when playing the MMORPG game, sometimes a captcha appears. The link doesn't change, just the content on screen changes. And If it clicks the buttons while the captcha is on screen, I will get banned. So, is there a way, so after every action, it checks if captcha is there, and if its there, it stops automatically and displays a message box, so I can manually fill captcha and then run the script again?
There are no conditionals in iMacros and it seems that game authors went to great lenghts to prevent such simple bots as you try to do.
You see, game companies earn money on you NOT being able to gain anything without tedious work. They WANT you to get tired and use real money to advance. That's the whole idea. Drop the games man, get a life.
You'll never beat spoiled kids waving a thousand-dollar platinium credit cards.

You can add PROMPT command inside your script to stop it from clicking anything. Then use entered value as captcha field value.
But that means no automatic loops, so - no real gain.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: New to IMacro, looping and stopping script when captcha

Post by chivracq » Mon Mar 24, 2014 3:48 pm

I agree with FastViper on his Analysis, though I have to confess that all the Knowledge I have acquired in iMacros comes from playing a (semi-strategic) Game myself some 8 or 9 years and automating the whole Playing with iMacros (which means I've more or less re-programed backwards the complete Game for my Scripts to take the best Decisions at the right moment)...

So if the Designers of your Game have implemented Captcha, it is meant to deliberately prevent people (like you :shock: ) from automating Actions on their Site...
But in your case, you could (try to) extract in each Loop the "Verification Code" Header and using EVAL(), upon Success trigger a MacroError (which will stop your Macro). Then you deal with the Captcha and you launch your Script again...
If you wanted the Prompt because of the Beep alerting you, you can, still using EVAL(), to conditionally play a Sound. Search my Posts on the Forum with those Keywords for a Thread explaining how to do so...
- (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...
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

Re: New to IMacro, looping and stopping script when captcha

Post by bestisme » Tue Mar 25, 2014 10:47 am

chivracq wrote:I agree with FastViper on his Analysis, though I have to confess that all the Knowledge I have acquired in iMacros comes from playing a (semi-strategic) Game myself some 8 or 9 years and automating the whole Playing with iMacros (which means I've more or less re-programed backwards the complete Game for my Scripts to take the best Decisions at the right moment)...

So if the Designers of your Game have implemented Captcha, it is meant to deliberately prevent people (like you :shock: ) from automating Actions on their Site...
But in your case, you could (try to) extract in each Loop the "Verification Code" Header and using EVAL(), upon Success trigger a MacroError (which will stop your Macro). Then you deal with the Captcha and you launch your Script again...
If you wanted the Prompt because of the Beep alerting you, you can, still using EVAL(), to conditionally play a Sound. Search my Posts on the Forum with those Keywords for a Thread explaining how to do so...
TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
that will extract the text, now how do i check if it was successful?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: New to IMacro, looping and stopping script when captcha

Post by chivracq » Tue Mar 25, 2014 10:45 pm

bestisme wrote:TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
that will extract the text, now how do i check if it was successful?
Goood, you are on the right path... Then you look how the Extract looks like and you build some EVAL() Statement on it...
- (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...
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

Re: New to IMacro, looping and stopping script when captcha

Post by bestisme » Wed Mar 26, 2014 2:22 am

if !EXTRACT = #EANF# //if extract was unsuccessful
set !VAR0=1 //I will check if this variable is 1, then the script will continue, else it will stop
else EVAL ("MacroError") //if !extract variable is not eanf, then it will stop

if !VAR0=1


then, i will paste it before each command, so if var0 is 1 i.e. text not found, it will continue next action


can you check and correct my mistakes?
please don't just post the corrected code, explain me my mistakes, so I can understand what I did wrong. :D


Edit- its not working :(

I get this error
SyntaxError: unknown command: IF, line 8 (Error code: -910)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: New to IMacro, looping and stopping script when captcha

Post by chivracq » Wed Mar 26, 2014 2:33 pm

No Conditional Statement (IF - ELSE - etc) directly in .iim Scripts, that's why you need to use EVAL().
Look at the Wiki-Page for EVAL() and at the Examples (with MacroError) then search the Forum for many other Examples with "SET !VAR1 EVAL"...

And you are correct to do the Check on #EANF# rather than (like I was thinking) on "Activation Code" or whatever is returned by the EXTRACT. If "#EANF#" is found, then you return any Value for !VAR1 (and you don't even need to do anything with !VAR! after), but if #EANF# is not found, then that will trigger the MacroError.
- (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...
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

Re: New to IMacro, looping and stopping script when captcha

Post by bestisme » Thu Mar 27, 2014 2:59 am

How do I write conditional statement? I checked on Eval() Wiki, and I think you meant this example-

Parse and compare currency. Conditionally save

Save EUR rates in USD only if it is above a certain threshold (1.3 USD). If it is below, stop the macro and give an error:

URL GOTO=http://www.xe.com/ucc/convert/?Amount=1&From=EUR&To=USD
SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=TD ATTR=TXT:*<SP>USD&&WIDTH:46%&&ALIGN:left EXTRACT=TXT
SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; s.replace(\"USD\",\"\"); var d=parseFloat(s); if(d < 1.3){MacroError(\"Euro is below 1.3 USD.\");} else d;")
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=* FILE=EuroRate.csv


But I Didn't Understand anything in it, can you explain me?

How do I put unequal sign? I mean, I can check if !EXTRACt is #EANF# is putting =. But what sign to put for check if !EXTRACT unequal #EANF#?

In above script, what does d in "else d" mean?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: New to IMacro, looping and stopping script when captcha

Post by chivracq » Thu Mar 27, 2014 8:33 am

Code: Select all

TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
PROMPT {{!VAR1}}
Tested on iMacros v8.8.1 for FF, Pale Moon 24.4.1 (=FF28), WinXP SP3.

The Prompt is for Testing...
- (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...
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

Re: New to IMacro, looping and stopping script when captcha

Post by bestisme » Fri Mar 28, 2014 3:04 am

Now the script automatically stops and I see this written
MacroError: Captcha found!, line 13 (Error code: -1340)

Even though the captcha didn't appear, the script automatically stops at this point. I was sitting was watching, and captcha didn't appear still script stopped :(

Here is the script

Code: Select all

    VERSION BUILD=8810214 RECORDER=FX
    TAB T=1
    URL GOTO=http://pokemoncreed.net/battle.php?opp=Mysterious%20Trainer
    
    SET !EXTRACT_TEST_POPUP NO
    
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
    
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=947 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=A ATTR=TXT:Golurk
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=9352 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=8416 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=A ATTR=TXT:Golurk
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=11051 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=2 TYPE=A ATTR=TXT:Golurk
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=14729 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=3 TYPE=SPAN ATTR=TXT:a
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=6954 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=A ATTR=TXT:Rotom
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=2 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=43068 ATTR=NAME:move
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
    
    TAG POS=1 TYPE=BUTTON ATTR=TXT:Restart<SP>Battle
    wait seconds=2
    TAG POS=1 TYPE=DIV ATTR=TXT:Verification<SP>Code EXTRACT=TXT
	SET !VAR1 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"Continue...\";} else {MacroError(\"Captcha found!\");} x;")
	
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: New to IMacro, looping and stopping script when captcha

Post by chivracq » Fri Mar 28, 2014 3:12 pm

Yep, normal... !EXTRACT keeps all the successive Extracts separated by a Colon until you do save it to a .CSV File or reset !EXTRACT to NULL, and therefor, at the 2nd Extract, it contains "#EANF#,#EANF#" which is different from "#EANF#".

So you need to add "SET !EXTRACT NULL" after each EVAL(MacroError) or before each Extract.
- (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...
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

Re: New to IMacro, looping and stopping script when captcha

Post by bestisme » Sat Mar 29, 2014 5:53 am

Thanks a lot, it works now!

But, just a small problem now...

Each time, to check captcha, it is taking 6 seconds. I run captcha checker 12 times, so it takes a lot of time for the script to complete once.

Any way to reduce the time it takes to check for captcha?


second thing, can I run something else like photoshop while the script keeps running in firefox?


Edit- just found, the captcha checking isn't what is taking time, this type of lines wait for 6 seconds, as i can see written tag waiting...(6)s

TAG POS=2 TYPE=INPUT:SUBMIT FORM=ACTION:battle.php?c=* ATTR=NAME:move

Any idea about how to reduce this time? The page is completely loaded, still it waits for 6 seconds :(
jorel
Posts: 6
Joined: Mon Mar 24, 2014 7:22 am

Re: New to IMacro, looping and stopping script when captcha

Post by jorel » Sat Mar 29, 2014 9:54 am

Any idea about how to reduce this time? The page is completely loaded, still it waits for 6 seconds :(

you can set http://wiki.imacros.net/!TIMEOUT_STEP to 0
can I run something else like photoshop while the script keeps running in firefox?
yes, if you have enough ram)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: New to IMacro, looping and stopping script when captcha

Post by chivracq » Sun Mar 30, 2014 4:20 am

Previous Answer by 'Jorel' is correct, though depending on some previous Action in your Script on the Page, if it requires some "thinking=loading...", "SET !TIMEOUT_STEP 1" might be safer in your case...

When your Script is running, you can minimize your Browser and do anything else like normally..., of course depending on your RAM...
- (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...
bestisme
Posts: 47
Joined: Sun Mar 23, 2014 7:37 am

Re: New to IMacro, looping and stopping script when captcha

Post by bestisme » Sun Mar 30, 2014 5:40 am

Thanks a lot, both jorel and chivracq.

chivracq, what did you mean here?
chivracq wrote:depending on some previous Action in your Script on the Page, if it requires some "thinking=loading...", "SET !TIMEOUT_STEP 1" might be safer in your case...
Post Reply