Imacros设置自定义WAIT SECONDS

时间:2014-05-09 22:32:46

标签: javascript imacros

我想通过弹出窗口设置自定义的WAIT SECONDS时间。

我有这段代码等了两秒钟:

var macroStart;
    macroStart ="CODE:";
    macroStart +="SET !ERRORIGNORE YES" + "\n"; 
    macroStart +="SET !TIMEOUT_TAG 1" + "\n";
    macroStart +="SET !TIMEOUT_STEP 1" + "\n";
    macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
    macroStart +=" SET !REPLAYSPEED FAST" + "\n";
    macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
    macroStart +="WAIT SECONDS=2" + "\n";


var i=0;
var n=prompt("Input the number",5)

for (i=1; i <= n; i++)
{

  iimPlay(macroStart,25)
}

iimDisplay("Success")

我试图将其更改为等待一段可变的时间,但它不起作用

var macroStart;
    macroStart ="CODE:";
    macroStart +="SET !ERRORIGNORE YES" + "\n"; 
    macroStart +="SET !TIMEOUT_TAG 1" + "\n";
    macroStart +="SET !TIMEOUT_STEP 1" + "\n";
    macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
    macroStart +=" SET !REPLAYSPEED FAST" + "\n";
    macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
    macroStart +="WAIT SECONDS=" + s + "\n";


var i=0;
var n=prompt("Input the number",5)
var s=prompt("Input seconds",0)

for (i=1; i <= n; i++)
{

  iimPlay(macroStart,25)
}

iimDisplay("Success")

我收到错误“在imacros框中等待秒未定义”。有解决方案吗我需要在var中运行Wait Seconds(

1 个答案:

答案 0 :(得分:0)

在你定义之前,你似乎试图使用's'。

var macroStart;
    macroStart ="CODE:";
    macroStart +="SET !ERRORIGNORE YES" + "\n"; 
    macroStart +="SET !TIMEOUT_TAG 1" + "\n";
    macroStart +="SET !TIMEOUT_STEP 1" + "\n";
    macroStart +="SET !TIMEOUT_PAGE 30" + "\n";
    macroStart +=" SET !REPLAYSPEED FAST" + "\n";
    macroStart +="SET !TIMEOUT_MACRO 150" + "\n";
    macroStart +="WAIT SECONDS=" +s+ "\n"; //<---'s' doesn't exist yet here


var i=0;
var n=prompt("Input the number",5)
var s=prompt("Input seconds",0) //<--- s only exists here, and later

您需要先声明并初始化's',或稍后再构建macroStart。

JavaScript试图在这里提供帮助,并将s转换为字符串'undefined'。如果这是一个像c或java这样的编译语言,你会得到一个编译器错误。