U have imacros script and I want to add wait seconds 60 When i reach to 20.
This is my code now:
var macro;
macro = "CODE:";
macro += "URL GOTO=http://example.com/msg?uid={{i}}\n";
macro +="TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:msg ATTR=ID:subject CONTENT=hello\n";
macro +="TAG POS=1 TYPE=TEXTAREA FORM=NAME:msg ATTR=ID:message CONTENT=hi\n";
macro +="TAG POS=1 TYPE=INPUT:IMAGE FORM=NAME:msg ATTR=ID:btn_save";
for (var i=1;i<300;i++){
iimSet("i",i)
iimPlay(macro)
}
iimDisplay("Script completed.");
And I also tried this one:
var macro;
macro = "CODE:";
macro += "URL GOTO=http://example.com/msg?uid={{i}}\n";
macro +="TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:msg ATTR=ID:subject CONTENT=hello\n";
macro +="TAG POS=1 TYPE=TEXTAREA FORM=NAME:msg ATTR=ID:message CONTENT=hi\n";
macro +="TAG POS=1 TYPE=INPUT:IMAGE FORM=NAME:msg ATTR=ID:btn_save";
iimDisplay("Send Macro via iimPlay");
retcode = iimPlay(macro);
var i=2
while(true){
if(i%20==0){
iimPlay("CODE: WAIT SECONDS=60")
}
iimSet("i",i);
iimPlay(macro);
}
for (var i=1;i<999;i++){
iimSet("i",i)
iimPlay(macro)
}
iimDisplay("Script completed.");
But both code are not working for me. Can anybody help me? Thank you !
In your first code change the loop in the following way:
for (i = 1; i < 300; i++){
if (i == 20)
iimPlayCode("WAIT SECONDS=60");
iimSet("i", i);
iimPlay(macro);
}
Related
first time using iMacros.
I want to run a loop 50x then when it is done, click the "Next" button and run the same loop again 50x, click "Next"... until "Next" is no longer clickable.
so far i have this working just 1 time:
SET !LOOP 1
TAG POS={{!LOOP}} TYPE=TD ATTR=CLASS:domain EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=Extract_{{!NOW:ddmmyy}}.csv
'click NEXT'
TAG POS=1 TYPE=A ATTR=TXT:Next
WAIT SECONDS=3
This code will help you,
just an explanation to familiarize you with imacros.
You need to create a script.js file in Imacros and paste this code.
do while loop will run the code inside the Braces forever.
Then we hardcode the two macros being used as shown below and assign it a javascript variable, inside the loop iimplay() is a javascript function that can run imacros code. so we run (macroStart)"check next button" to check if next still exists.
The function iimGetLastExtract() will get the last extracted value from the code.
If the extracted text is next then break the infinite loop.
else run the "extract and send to csv file" macro (macro2).
Code:
var macro1;
macro1 = "CODE:";
macro1 += "SET !ERRORIGNORE YES" + "\n";
macro1 += "TAG POS=1 TYPE=A ATTR=TXT:Next EXTRACT=TXT" + "\n";
var macro2;
macro2 = "CODE:" + "\n";
macro2 += "SET !ERRORIGNORE YES" + "\n";
macro2 += "TAG XPATH=(/html/body//td[contains(#class,'domain')])[{{j}}] EXTRACT=TXT" + "\n";
macro2 += "SAVEAS TYPE=EXTRACT FOLDER=C:/Users/Naren/Desktop/ FILE=output.csv" + "\n";
var macro3;
macro3 = "CODE:" + "\n";
macro3 += "SET !ERRORIGNORE YES" + "\n";
macro3 += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
macro3 += "WAIT SECONDS=5" + "\n";
for(var j = 1; j <= 50; j++){
iimSet("j",j);
iimPlay(macro2);
}
iimPlay(macro3);
do{
iimPlay(macro1);
var macro1Extract = iimGetLastExtract();
if (macro1Extract !== 'Next') {
break;
}
for(var j = 1; j <= 50; j++){
iimSet("j",j);
iimPlay(macro2);
}
iimPlay(macro3);
}while (true);
I need help with iMacros.
I have a task which consists of two parts:
1) Go to a website and fill out a form.
URL GOTO=https://example.com/registration
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:NQKtn CONTENT=ggg
2) Check if the text Mytext exists (which has to appear after filling out the form).
The task of the script is to save the string ggg to file.txt if the text is found, and to pass it if it's not.
How can I solve this problem? Thanks very much!
Example with Javascript and iMacros for Firefox:
var FilePath = "c:\\yourfile.txt";
var your_newtext = "ggg";
var macro = "CODE:";
macro += "URL GOTO=https://example.com/registration\n";
macro += "SET !ERRORIGNORE YES\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:NQKtn CONTENT="+your_newtext+"\n";
macro += "WAIT SECONDS = 0.1\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:NQKtn EXTRACT=TXT\n";
iimPlay(macro);
var last_extract = iimGetLastExtract();
var msg;
if(last_extract == "#EANF#" || last_extract == ""){
msg = "NOT FOUND\n";
}else{
msg = "FOUND: "+last_extract+"\n";
}
var file_o = imns.FIO.openNode(FilePath);
imns.FIO.appendTextFile(file_o, msg);
For example:
On the page are 3 diferent picture
http://example.com/1.png
http://example.com/4.png
http://example.com/9.png
http://example.com/1.png
Please correct my code
TAG POS=1 TYPE=DIV ATTR=ID:site_loader EXTRACT=HTM
SET !VAR1 EVAL("var s=\"{{!EXTRACT}}\"; for(var i = 0; i < 9; i++) {var res=(s.split(i.\".png\").length - 1); MacroError(i); if (res=2) break; }")
TAG POS=1 TYPE=IMG ATTR=SRC:/surf/{{res}}.png
What else??
How to find 2 same picture and Save or click it ?
For your case I suggest this way:
SET listNum EVAL("\"{{!EXTRACT}}\".match(/\d(?=\.png)/g).toString();")
SET doubleNum EVAL("var d; var a = \"{{listNum}}\".split(\",\"); for (i in a) {if (a.indexOf(a[i]) != i) {d = a[i]; break;}} d;")
TAG POS=1 TYPE=IMG ATTR=SRC:/surf/{{doubleNum}}.png
Please check below some a tag link in there I want to receive bosWDC5M1C8oeVu, DaleyBlind_fan, jkjinc1 like this 3word with show this in my listbox or textbox.
#bosWDC5M1C8oeVu
#DaleyBlind_fan
#jkjinc1
www.stackoverflow.com
In my textbox or listbox show line process.
bosWDC5M1C8oeVu
DaleyBlind_fan
jkjinc1
see this code not received data in my listbox what I am want.
HtmlElementCollection bColl = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement bEl in bColl)
{
if (bEl.GetAttribute("data-aria-label-part") != null)
listBox1.Items.Add(bEl.GetAttribute("href"));
}
this code I am getting all href link but I need only my detection line what I am want.
You are not formatting your if statement correctly (you forgot the curly brackets). Try this code:
HtmlElementCollection bColl = webBrowser1.Document.GetElementsByTagName("a");
foreach (HtmlElement bEl in bColl)
{
if (bEl.GetAttribute("data-aria-label-part") != null) {
listBox1.Items.Add(bEl.GetAttribute("href"));
}
}
Note the { after != null) and the } after ("href"));.
I hope this helps.
IMACROS.
I have to find out a invitation code to a site, it's a code that contains letters(a-z) and numbers(0-9). There are 3 missing, the XXX for exemple. But, how do I make a "for" to considerate letters and numbers on Imacros? I have to use javascript?
This is the code I have:
VERSION BUILD=8820413 RECORDER=FX
TAB T=1
TAB CLOSEALLOTHERS
URL GOTO=(url site)
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:confirmcod.php ATTR=NAME:cod CONTENT=123XXXabc
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:confirmcod.php ATTR=*
One way to do this without using Javascript is to preload a datasource with all of the possible combinations for the link. Iterate over this document until you find the proper link.
VERSION BUILD=8820413 RECORDER=FX
TAB T=1
TAB CLOSEALLOTHERS
SET !DATASOURCE c:\mysource
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=(url site)
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:confirmcod.php ATTR=NAME:cod CONTENT={{!COL1}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=ACTION:confirmcod.php ATTR=*
Wiki page for iMacro Datasource.
If you want to use javascript you will need to use iimPlay to generate the macro code on the fly. The example below iterates checks a random strings until iMacros returns 1 or sOK.
// possible keys for the link
var keys = '0123456789abcdefghijklmnopqrstuvwxyz';
// array to store past keys
var keyArray = [];
var myKey = "";
var i, j, k = 0;
var pageNotFound = true;
var macro = "";
var retCode = 0;
var myURL = "http://www.google.com";
do
{
i = keys.charAt(Math.floor(Math.random()*keys.length))
j = keys.charAt(Math.floor(Math.random()*keys.length));
k = keys.charAt(Math.floor(Math.random()*keys.length));
myKey = i + j + k;
if (keyArray.indexOf(myKey, 0) < 0)
{
keyArray.push(myKey);
// run imacro code with this key
macro = "CODE:";
macro += "TAB T=1\n";
macro += "TAB CLOSEALLOTHERS\n";
macro += "URL GOTO=" + myURL + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:gbqf ATTR=ID:gbqfq CONTENT=" + myKey + "\n";
macro += "TAG POS=1 TYPE=BUTTON FORM=ID:gbqf ATTR=ID:gbqfb\n";
retCode = iimPlay(macro);
// check if the page is found
if (retCode)
{
// if page is found set pageNotFound = false;
pageNotFound = false;
}
} else {
// key has been used already, try a different one.
}
} while(pageNotFound);