iMacros: click button or do not click (random choice)

1.1k views Asked by At

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

There are 2 answers

1
edinvnode On
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.

2
Shugar On

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