iMacros: click button or do not click (random choi

2019-08-08 20:48发布

How can I set random choice for button 'click' or 'don't click'?

In this example I need let iMacros make random action between like action and do nothing.

TAG POS=1 TYPE=BUTTON ATTR=TXT:Like

2条回答
The star\"
2楼-- · 2019-08-08 21:37

As one of the ways to do what you need:

SET butTxt "Like"
SET butTxt EVAL("(Math.floor(2*Math.random()) == 0) ? 'No such button!' : '{{butTxt}}';")
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=BUTTON ATTR=TXT:{{butTxt}}
SET !ERRORIGNORE NO
SET !TIMEOUT_STEP 6
查看更多
Animai°情兽
3楼-- · 2019-08-08 21:45
var macro;

macro = "CODE:";
macro += "SET !TIMEOUT_STEP 1" + "\n";
macro += "TAG POS=1 TYPE=BUTTON ATTR=TXT:Like" + "\n";
while (true) {

    var random = getRandomInt(1, 10);

    if (random < 5) {
        iimPlay(macro)
    }

}

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

Try this simple .js solution. I made it so if the random number is less then 5 to click the button. Else do nothing.

You can change it the way you want it. You have to save the JS code as .js . Nothing other that that will work.

查看更多
登录 后发表回答