Have iMacros pickup where left off when starting script?

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
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
Post Reply
RDKamikaze
Posts: 3
Joined: Tue Dec 15, 2009 8:12 am

Have iMacros pickup where left off when starting script?

Post by RDKamikaze » Tue Dec 15, 2009 8:28 am

I'm not really sure how to word exactly what I'm looking for so I thought a post here would be helpful. Here's what I'm trying to do:

I want iMacros to start (for the first run) with a value 1, then increase by 1 on every loop like normal. however, if I hit stop on accident or the webpage closes, I want to be able to open up the iMacros and have it continue at the number that it left off on. How would I go about doing that?

Ex. Go to google and have it search the number 1. On loop, increase by 1 to searching for 2. Increase for 3, 4, etc. Firefox closes or Stop is pressed (let's say at #50), leading to me having to begin again. When I hit start iMacros continues from 50 and keeps on going.

Possible? I've been fiddling with different things all night and here's what I have so far:

Code: Select all

VERSION BUILD=6251204 RECORDER=FX
CMDLINE !DATASOURCE test2.txt
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!LOOP}}
SET !VAR1 {{!COL1}}
ADD !VAR1 1
ADD !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\jytrewer\Documents\iMacros\Datasources FILE=test2.txt


TAB T=1
URL GOTO=http://www.google.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG&&VALUE:Google<SP>Search

WAIT SECONDS=2
Hannes, Tech Support

Re: Have iMacros pickup where left off when starting script?

Post by Hannes, Tech Support » Tue Dec 15, 2009 9:39 am

You'd need to use a script that e.g. writes a log, and on subsequent runs checks that log for the last successful number.
RDKamikaze
Posts: 3
Joined: Tue Dec 15, 2009 8:12 am

Re: Have iMacros pickup where left off when starting script?

Post by RDKamikaze » Tue Dec 15, 2009 5:11 pm

Would I be able to write that script into part of iMacros? Or maybe I'm just better off just going into VisualBasic and doing it?
Hannes, Tech Support

Re: Have iMacros pickup where left off when starting script?

Post by Hannes, Tech Support » Wed Dec 16, 2009 7:26 pm

A standalone macro can't perform the neccessary steps. You need a script. If you need to stick to the FF plugin, you can use the JavaScript Scripting Interface. With the iMacros Scripting Interface you may use whatever language you want (e.g. VBS).
RDKamikaze
Posts: 3
Joined: Tue Dec 15, 2009 8:12 am

Re: Have iMacros pickup where left off when starting script?

Post by RDKamikaze » Thu Dec 17, 2009 1:48 am

Wow thanks!! But I don't know squat about Javascript so I'll have to read into it. Could you point me in the general direction of where I could get started with the script I'm looking for? :)

Thanks a ton!!
Hannes, Tech Support

Re: Have iMacros pickup where left off when starting script?

Post by Hannes, Tech Support » Thu Dec 17, 2009 7:07 am

There are some JavaScript samples in the iMacros macro folder. And then there's a lot more when searching this forum.

Feel free to open a new thread if you have more specific questions like "How to read/write to a file".
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Have iMacros pickup where left off when starting script?

Post by siniy » Wed Dec 08, 2010 1:37 pm

I know its been a while. But maybe someone find this helpful.
This code will allow you to remember last loop value and continue from last position. You don't need javascript or scripting edition.

Code: Select all

'File which contains last loop value. Initial value "0"
SET !ERRORIGNORE YES
SET !DATASOURCE c:\LastLoop.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE 1
'If file does not exists, it will be created with initial value 0
SET !VAR1 0
'If file exists read and increment value.
'If its our first run we will start from 1st line at our file with data.
SET !VAR1 {{!COL1}}
ADD !VAR1 1
'File with out data
SET !DATASOURCE c:\data.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!VAR1}}
'Remove file and store incremented loop value
FILEDELETE NAME=C:\LastLoop.csv
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=c:\ FILE=LastLoop.csv
PROMPT {{!COL1}}
Loop count stored at c:\LastLoop.csv. It is created automatically, to reset loop count remove the file or set value to 0.
ranjancom2000
Posts: 11
Joined: Mon Feb 09, 2009 11:07 am

Re: Have iMacros pickup where left off when starting script?

Post by ranjancom2000 » Fri Dec 10, 2010 9:51 am

'File which contains last loop value. Initial value "0"
SET !ERRORIGNORE YES
SET !DATASOURCE c:\LastLoop.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE 1
'If file does not exists, it will be created with initial value 0
SET !VAR1 0
'If file exists read and increment value.
'If its our first run we will start from 1st line at our file with data.
SET !VAR1 {{!COL1}}
ADD !VAR1 1
'File with out data
SET !DATASOURCE c:\data.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!VAR1}}
'Remove file and store incremented loop value
FILEDELETE NAME=C:\LastLoop.csv
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=c:\ FILE=LastLoop.csv
PROMPT {{!COL1}}
I tried the code but I am not able the run the script in loop.

How i need to apped to my script

VERSION BUILD=6900210
TAB T=1
TAB CLOSEALLOTHERS
CMDLINE !DATASOURCE c:\my-record.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://ss.info/script/test.php
TAG POS=1 TYPE=FONT ATTR=TXT:{{!COL1}}
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Have iMacros pickup where left off when starting script?

Post by siniy » Fri Dec 10, 2010 11:32 am

Code: Select all

'File which contains last loop value. Initial value "0"
SET !ERRORIGNORE YES
SET !DATASOURCE c:\LastLoop.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE 1
'If file does not exists, it will be created with initial value 0
SET !VAR1 0
'If file exists read and increment value.
'If its our first run we will start from 1st line at our file with data.
SET !VAR1 {{!COL1}}
ADD !VAR1 1
'Remove file and store incremented loop value
FILEDELETE NAME=C:\LastLoop.csv
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=c:\ FILE=LastLoop.csv


TAB CLOSEALLOTHERS
CMDLINE !DATASOURCE c:\my-record.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!VAR1}}
URL GOTO=http://ss.info/script/test.php 
TAG POS=1 TYPE=FONT ATTR=TXT:{{!COL1}}
'Google test
'URL GOTO=http://google.com
'TAG POS=1 TYPE=INPUT:TEXT  ATTR=* CONTENT={{!COL1}}
You should use {{!VAR1}} as loop variable.
ranjancom2000
Posts: 11
Joined: Mon Feb 09, 2009 11:07 am

Re: Have iMacros pickup where left off when starting script?

Post by ranjancom2000 » Wed Jan 05, 2011 1:53 pm

SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE 1
'If file does not exists, it will be created with initial value 0
SET !VAR1 0
'If file exists read and increment value.
'If its our first run we will start from 1st line at our file with data.
SET !VAR1 {{!COL1}}
ADD !VAR1 1
'Remove file and store incremented loop value
FILEDELETE NAME=C:\LastLoop.csv
SET !EXTRACT NULL
SET !EXTRACT {{!VAR1}}
SAVEAS TYPE=EXTRACT FOLDER=c:\ FILE=LastLoop.csv


TAB CLOSEALLOTHERS
CMDLINE !DATASOURCE c:\url.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!VAR1}}
SET !EXTRACT_TEST_POPUP NO
URL GOTO=https://www.co.cc/my_account/my_account ... domain.php
TAG POS=1 TYPE=B ATTR=TXT:{{!COL2}}
TAG POS=1 TYPE=INPUT:BUTTON FORM=NAME:NoFormName ATTR=ID:buttonbutton
'Comment: New page loaded
This is the script I am using now i am getting error
Variable {{!col1}} not defined. It is not an internal variable and no external datasource was defined.
Post Reply