【问题标题】:IMacro Script Random Wait TimeIMacro 脚本随机等待时间
【发布时间】:2014-04-21 00:33:45
【问题描述】:

所以我的脚本如下:

SET !ERRORIGNORE YES
SET !ERRORIGNORE YES
SET !TIMEOUT_TAG 1
SET !TIMEOUT_STEP 1
SET !TIMEOUT_PAGE 30
SET !REPLAYSPEED FAST
TAB T=1
URL GOTO=http://www.youlikehits.com/stats.php
TAG POS=1 TYPE=IMG ATTR=SRC:http://www.youlikehits.com/YLHicons/yt50.png
TAG POS=1 TYPE=A ATTR=TXT:View
TAB T=2
WAIT SECONDS = 35
TAB T=1

我希望它等待 35-45 秒之间的随机数,而不是“等待秒数 = 35”。如果您能编辑此脚本,我将不胜感激。我研究了很多,但仍然不明白该怎么做。

【问题讨论】:

    标签: random time macros delay wait


    【解决方案1】:

    SET !VAR1 EVAL("Math.floor(Math.random()*45 + 35);")

    等待秒={{!VAR1}}

    【讨论】:

      【解决方案2】:
      'set the delay lower limit, this can be changed
      SET !VAR1 1800
      'set the remaining time interval that need randomized
      SET !VAR2 1800
      'calculate the random number
      SET !VAR3 EVAL("var randomNumber=Math.floor(Math.random()*\"{{!VAR2}}\" +\"{{!VAR1}}\"); randomNumber;") 
      WAIT SECONDS={{!VAR3}}
      

      【讨论】:

        【解决方案3】:

        这是一个如何使用 iMacros 和 JavaScript 脚本的示例。

        Loop in Imacros using Javascript

        下面是如何在 JavaScript 中创建随机数。

        Generating random whole numbers in JavaScript in a specific range?

        部分代码如下所示:

        //generate random time
        var time=getRandomInt(35,45);
        
        //set the time to macro and play
        iimSet("time",time)
        iimPlay(macro)
        
        
        /**
         * Returns a random integer between min and max
         * Using Math.round() will give you a non-uniform distribution!
         */
        function getRandomInt (min, max) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多