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

这一生的挚爱 提交于 2020-01-05 09:22:46

问题


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

回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/30775851/imacros-click-button-or-do-not-click-random-choice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!