imacros/ javascript 在下一个按钮上使用条件循环
imacros/ javascript loop with condition on next button
菜鸟javascript,
我试图制作一个我从 Whosebug 帖子中找到的脚本来在我的宏中工作,但它没有按应有的方式工作,
我想做的是:
1- 使用从 csv 文件中提取的关键字搜索 google,
2- 提取并保存内容。
3- 转到下一页结果,提取并保存,
4- 它应该继续下一步按钮,直到没有下一步按钮,
5- 然后它应该转到 csv 文件中的下一个关键字。
循环有效,但我不知道为什么它只点击下一步按钮 4 次,然后继续下一个关键字。
我一开始尝试了 2 种 "while" 条件的变体,但结果是一样的。
感谢您对此的帮助,
我在 windows 7 32 位和 macros 8.9.7 上使用 FF 55
这是我的宏,不包括提取和保存,
var macro;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE keywords.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{RowNo}}" + "\n";
macro += "URL GOTO=https://www.google.com/ncr" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";
var NextBtnCheck=iimGetLastExtract();
var NextButton;
NextButton = "CODE:";
NextButton += "SET !ERRORIGNORE YES" + "\n";
NextButton += "SET !EXTRACT_TEST_POPUP NO" + "\n";
NextButton += "TAB T=1" + "\n";
NextButton += "WAIT SECONDS=1" + "\n";
NextButton += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
NextButton += "WAIT SECONDS=0.5" + "\n";
for(var m=1; m<60; m++)
{iimSet("RowNo",m)
iimPlay(macro)
var n = 0
var n= iimPlay(NextButton);
do
{
iimSet("n",n)
iimPlay(NextButton);
if (NextBtnCheck !== "#EANF#");
break;
n++;
}
while(true)
{
iimSet("n",n);
iimPlay(NextButton);
}
}
我已经像这样更正了您的代码:
var macro = "SET !DATASOURCE keywords.csv" + "\n";
macro += "SET !DATASOURCE_LINE {{RowNo}}" + "\n";
macro += "URL GOTO=https://www.google.com/ncr" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";
var NextButton = "TAB T=1" + "\n";
NextButton += "WAIT SECONDS=1" + "\n";
NextButton += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
NextButton += "WAIT SECONDS=0.5" + "\n";
for(var m=1; m<60; m++) {
iimSet("RowNo",m)
iimPlayCode(macro)
do {
var NextBtnCheck = iimPlayCode(NextButton);
if (NextBtnCheck != 1)
break;
} while(true)
}
菜鸟javascript, 我试图制作一个我从 Whosebug 帖子中找到的脚本来在我的宏中工作,但它没有按应有的方式工作,
我想做的是:
1- 使用从 csv 文件中提取的关键字搜索 google, 2- 提取并保存内容。 3- 转到下一页结果,提取并保存, 4- 它应该继续下一步按钮,直到没有下一步按钮, 5- 然后它应该转到 csv 文件中的下一个关键字。
循环有效,但我不知道为什么它只点击下一步按钮 4 次,然后继续下一个关键字。
我一开始尝试了 2 种 "while" 条件的变体,但结果是一样的。
感谢您对此的帮助, 我在 windows 7 32 位和 macros 8.9.7 上使用 FF 55 这是我的宏,不包括提取和保存,
var macro;
macro = "CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !EXTRACT_TEST_POPUP NO" + "\n";
macro += "SET !DATASOURCE keywords.csv" + "\n";
macro += "SET !DATASOURCE_COLUMNS 1" + "\n";
macro += "SET !LOOP 1" + "\n";
macro += "SET !DATASOURCE_LINE {{RowNo}}" + "\n";
macro += "URL GOTO=https://www.google.com/ncr" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";
var NextBtnCheck=iimGetLastExtract();
var NextButton;
NextButton = "CODE:";
NextButton += "SET !ERRORIGNORE YES" + "\n";
NextButton += "SET !EXTRACT_TEST_POPUP NO" + "\n";
NextButton += "TAB T=1" + "\n";
NextButton += "WAIT SECONDS=1" + "\n";
NextButton += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
NextButton += "WAIT SECONDS=0.5" + "\n";
for(var m=1; m<60; m++)
{iimSet("RowNo",m)
iimPlay(macro)
var n = 0
var n= iimPlay(NextButton);
do
{
iimSet("n",n)
iimPlay(NextButton);
if (NextBtnCheck !== "#EANF#");
break;
n++;
}
while(true)
{
iimSet("n",n);
iimPlay(NextButton);
}
}
我已经像这样更正了您的代码:
var macro = "SET !DATASOURCE keywords.csv" + "\n";
macro += "SET !DATASOURCE_LINE {{RowNo}}" + "\n";
macro += "URL GOTO=https://www.google.com/ncr" + "\n";
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=ID:tsf ATTR=ID:lst-ib CONTENT={{!COL1}}" + "\n";
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:tsf ATTR=NAME:btnK" + "\n";
var NextButton = "TAB T=1" + "\n";
NextButton += "WAIT SECONDS=1" + "\n";
NextButton += "TAG POS=1 TYPE=A ATTR=TXT:Next" + "\n";
NextButton += "WAIT SECONDS=0.5" + "\n";
for(var m=1; m<60; m++) {
iimSet("RowNo",m)
iimPlayCode(macro)
do {
var NextBtnCheck = iimPlayCode(NextButton);
if (NextBtnCheck != 1)
break;
} while(true)
}