当他到达文件末尾时,如何从文件中获取相同行的宏

时间:2015-10-10 06:16:24

标签: loops imacros

当他到达文件末尾时,如何从txt文件中获取相同行的宏。我有脚本,从文件中获取有35个链接的google + url页面,然后我有另一个文件,我需要在墙上发布网站链接。每个网络链接都需要在35个Google +网页上发布。目前脚本访问的所有url的帖子第一个链接从文件,因为我需要,但当他来到文件的末尾,宏停止工作。任何消化都是我能做到的吗?

这是我的剧本

var macros;
var loop = 1;
macros = "CODE:";
macros += "SET !DATASOURCE google_pages.txt" + "\n";
macros += "SET !DATASOURCE_LINE {{i}}" + "\n";
macros += "URL GOTO={{!COL1}}" + "\n";
macros += "TAG POS=1 TYPE=DIV ATTR=CLASS:\"kqa es\"" + "\n";
macros += "SET !DATASOURCE links.txt" + "\n";
macros += "SET !DATASOURCE_LINE {{!LOOP}}" + "\n";
macros += 'EVENTS TYPE=KEYPRESS SELECTOR="div[class=\\"df b-K b-K-Xb URaP8 editable\\"]" CHARS={{!COL1}}' + "\n";
macros += "TAG POS=1 TYPE=DIV ATTR=CLASS:\"d-k-l b-c b-c-Ba qy jt\"" + "\n";
loop += prompt("How many times to play macros?:", loop);

for(i = 1; i <= loop; i++) {
    iimSet("i",i)
    iimDisplay("Loop Plays: "+i)
    iimPlay(macros)
}

1 个答案:

答案 0 :(得分:1)

我理解这个问题,您应该查看以下代码段:

var linesInTxt = 35;
var numToRepeat = 2;
var loop = numToRepeat*linesInTxt;
for (i = 1; i <= loop; i++) {
    var j = (i % linesInTxt == 0) ? linesInTxt : i % linesInTxt;
    iimSet("i", j);
    // further code here
}