我的javascript imacro代码有什么问题

时间:2018-06-07 11:51:48

标签: javascript if-statement while-loop imacros

我尝试在javascript中为imacros编写脚本。但是,它不起作用。当我按下播放时,它什么也没做。没有错误,没有任何错误。我有一个朋友给我的imacro脚本(javascript imacro),这是有效的,但我没有。任何人都可以告诉我我做错了什么。

PS:我是初学者编码器。

我的代码:

var macro;
macro = "CODE:"; 
macro +="SET !TIMEOUT_STEP 2" + "\n";
macro +="URL GOTO=LINK_TO_SITE" + "\n";
macro +="EVENT TYPE=KEYPRESS SELECTOR=* KEY=35" + "\n";
macro +="WAIT SECONDS=2" + "\n";
macro +="EVENT TYPE=KEYPRESS SELECTOR=* KEY=35" + "\n";
macro +="WAIT SECONDS=2" + "\n";

var macro1;
macro1 = "CODE:";
macro1 +="TAG POS={{i}} TYPE=A ATTR=TXT:*<SP>Open<SP>Link" + "\n";

var macro2;
macro2 = "CODE:";
macro2 +="TAG POS={{j}} TYPE=BUTTON ATTR=TXT:Create<SP>Link" + "\n";

var macro3;
macro3 = "CODE:";
macro3 +="TAG POS=1 TYPE=DIV ATTR=TXT:View<SP>More" + "\n";

var macro4;
macro4 = "CODE:";
macro4 +="WAIT SECONDS=180" + "\n";

iimPlay(macro)

var i = 11;
while (i > 0) {

    iimSet("i",i)
    iimPlay(macro1)

    var j = 1;
    while (j <= 61) {

        iimSet("j", j)
        iimPlay(macro2)

        if (j % 30 == 0) {

            iimPlay(macro3)
        }

        if (j == 60) {

            iimPlay(macro4)
        }

        j++;
    }

    i--;
}

1 个答案:

答案 0 :(得分:0)

你在While(i < 11)i == 11时说,所以它不起作用,你的时间永远不会循环。你需要像这样处理:

var macro;
macro = "CODE:"; 
macro +="SET !TIMEOUT_STEP 2" + "\n";
macro +="URL GOTO=LINK_TO_SITE" + "\n";
macro +="EVENT TYPE=KEYPRESS SELECTOR=* KEY=35" + "\n";
macro +="WAIT SECONDS=2" + "\n";
macro +="EVENT TYPE=KEYPRESS SELECTOR=* KEY=35" + "\n";
macro +="WAIT SECONDS=2" + "\n";

var macro1;
macro1 = "CODE:";
macro1 +="TAG POS={{i}} TYPE=A ATTR=TXT:*<SP>Open<SP>Link" + "\n";

var macro2;
macro2 = "CODE:";
macro2 +="TAG POS={{j}} TYPE=BUTTON ATTR=TXT:Create<SP>Link" + "\n";

var macro3;
macro3 = "CODE:";
macro3 +="TAG POS=1 TYPE=DIV ATTR=TXT:View<SP>More" + "\n";

var macro4;
macro4 = "CODE:";
macro4 +="WAIT SECONDS=180" + "\n";


var i = 11;
while (i > 0) {

    iimSet("i",i)
    iimPlay(macro1)

    var j = 1;
    while (j <= 61) {

        iimSet("j", j)
        iimPlay(macro2)

        if (j % 30 == 0) {

            iimPlay(macro3)
        }

        if (j == 60) {

            iimPlay(macro4)
        }

        j++;
    }

    i--;
}