HELP: Goto specfic lines in script to do repeat if fail

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

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.

HELP: Goto specfic lines in script to do repeat if fail

by hackenggr on Thu Dec 08, 2016 6:09 pm

Hi

I searched for the problem but not found somewhere in forum or in google so writing here. I am not the programmer so might not be searching right thing, just want to automate the browser to solve the captcha but want to return to the middle of the script if it is wrong and I can't figure out how to place the lables in there that do this task if that appear go back to line xx and start over the task and if succes go to end and wait or time specified and go back to start and do over.

HERE is the complete script I am tinkering with

Code: Select all
SET apikey "9kwCAPTCHA SOLVING APK here"

SET !ERRORIGNORE YES
URL GOTO="SOME URL"
'REFRESH
WAIT SECONDS=10

URL GOTO=javascript:window.scrollBy(0,450)

START:

FILEDELETE NAME=d:\xyz.jpg
SET !ERRORIGNORE NO
ONDOWNLOAD FOLDER=d:\ FILE=xyz.jpg
WAIT SECONDS=3
TAG POS=1 TYPE=DIV ATTR=ID:adcopy-puzzle-image CONTENT=EVENT:SAVE_ELEMENT_SCREENSHOT
WAIT SECONDS=5

TAB OPEN
TAB T=2
URL GOTO=http://www.9kw.eu/grafik/form.html
TAG POS=1 TYPE=INPUT ATTR=NAME:apikey CONTENT={{apikey}}
TAG POS=1 TYPE=INPUT ATTR=NAME:prio CONTENT=0
'TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:selfsolve CONTENT=NO
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:confirm CONTENT=YES
'TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ACTION:/index.cgi ATTR=NAME:case-sensitive CONTENT=NO
TAG POS=1 TYPE=INPUT ATTR=NAME:source CONTENT=imacros
TAG POS=1 TYPE=INPUT ATTR=NAME:file-upload-01 CONTENT=d:\xyz.jpg
TAG POS=1 TYPE=INPUT ATTR=TYPE:submit
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT_STEP 180
TAG POS=1 TYPE=INPUT ATTR=NAME:captchaid EXTRACT=TXT
SET !VAR5 {{!EXTRACT}}
'Clean the !EXTRACT variable for the next task
SET !EXTRACT NULL
'Extract the characters that are recoginzed from the picture of captcha.
TAG POS=1 TYPE=INPUT ATTR=NAME:result EXTRACT=TXT
WAIT SECONDS=1
TAB CLOSE

'Step 4: Check the captcha answer (text or nothing like #EANF# = Extraction Anchor Not Found)
SET !VAR6 EVAL("if (\"{{!EXTRACT}}\" == \"#EANF#\") {var x = \"\";} else {var x = \"{{!EXTRACT}}\";} x;")
'Clean the !EXTRACT variable for the next task
SET !EXTRACT NULL

'Step 5: Fill the recognized characters to the verification box
TAB T=1
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:adcopy_response CONTENT={{!VAR6}}
WAIT SECONDS=5
SET !ERRORIGNORE YES
TAG POS=1 TYPE=INPUT:SUBMIT ATTR=ID:SOMETHING

'Step 6: Check and send the captcha feedback back to the captcha service (OK:1, NotOK:2)
SET !VAR7 {{!EXTRACT}}
SET !EXTRACT NULL
SET !VAR8 EVAL("if ('{{!VAR7}}' == \"TXT:Wrong<SP>Captchas\")) {var x = \"2\";} else {var x = \"1\";} x;")
TAB OPEN
TAB T=2
URL GOTO=http://www.9kw.eu/index.cgi?source=imacros&action=usercaptchacorrectback&apikey={{apikey}}&correct={{!VAR8}}&id={{!VAR5}}
WAIT SECONDS=2
TAB CLOSE

TAB T=1
SET EVAL("if ({{!VAR8}}==\"2\") {GOTO=START;} else {GOTO=END;}")

END:

WAIT SECONDS=310
SET !ERRORIGNORE NO
'Wait a random number (1 to 10) of seconds
SET !VAR10 EVAL("Math.floor(Math.random()*10 + 1);")
WAIT SECONDS={{!VAR10}}


Now I want the expert opinion on correcting the STEP 6 to search for the text but not hault if text found enter x = 2 to !VAR8 if not found enter x= 1 to !VAR8 and adding the loop command to do over not to the start just to the few line down if !VAR8 = 2 but iMacro give error on line 9 you can understand with START and END what I am trying to do those GOTO command work in bat file for command prompt but I have no idea how to do it here.

Also how can add some command to keep trying to refresh the page if internet disconnect during the task it connects again but macro stop I want it to keep try to go to the start and if page open do the task and after wait time if net is off it keep looping to open page and when it open it go forward
User avatar
hackenggr
 
Posts: 2
Joined: Thu Dec 08, 2016 5:29 pm

Return to iMacros for Firefox

Who is online

Users browsing this forum: Bing [Bot] and 11 guests

-->