Imacros: Random wait time?

2019-07-28 08:48发布

问题:

I'm trying to make a random wait between 30 minutes to one hour.

The code I'm using is supposed to do this, but after the last line of code the script simply stops.

Here's the script

TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:true-random-integer-generator-min CONTENT=900
TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:true-random-integer-generator-max CONTENT=3600
WAIT SECONDS=1
TAG POS=1 TYPE=SPAN ATTR=ID:true-random-integer-generator-result&&TXT:* EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
WAIT SECONDS={{!VAR1}}
SET !EXTRACT NULL

回答1:

'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}}