AutoJs刷好策

let x = device.width;
let y = device.height;
let intervalTime = 0;
let offsets = [-1300, -1200, -1000, 1000, 1100, 1200, 1300];

let execution = null;
let fuck = null;

function turnPage(){
    let offset = offsets[Math.floor((Math.random()*offsets.length))]

    swipe(x/2, y/2, x/7, y/2, 500);
    sleep(intervalTime*1000+offset);
}

function run(){
	var thread = new Thread(function() {
		while (true) {
            //检测页数是否存在
            turnPage();
            //检测弹窗
            if(text("知道了").exists()){
                let ok = text("知道了").findOne();
                ok.click();
                toast("I know")
            }
           
        }
	});
	return thread;
};

let window = floaty.window(
    <frame>
        <input id="time" text="20" bg="#FFCCCCCC" w="90" h="40"/>
        <button id="sub" w="40" h="40" marginTop="41">-</button>
        <button id="add" w="40" h="40" marginTop="41" marginLeft="41">+</button>
        <button id="action" text="开始" w="90" h="40" marginTop="82"/>
        <button id="closeAll" text="关闭" w="90" h="40" bg="#FFFF0000" marginTop="125"/>
    </frame>
);

window.exitOnClose();

window.sub.click(()=>{
    let time = parseInt(window.time.getText());
    if(time == 20){
        toast("时间不能低于20秒");
    }else{
        window.time.setText((time-1).toString());
    }
});

window.add.click(()=>{
    let time = parseInt(window.time.getText());
    if(time == 120){
        toast("时间不能超过120秒");
    }else{
        window.time.setText((time+1).toString());
    }
});

window.action.click(()=>{
    if(window.action.getText() == '开始'){
        intervalTime = parseInt(window.time.getText());
        fuck = run()
        fuck.start();
        toast("fuck开始!");
        window.action.setText('停止');
    }else{
        if(fuck.isAlive()){
            fuck.interrupt();
        }
        toast("突然停下来了!");
        window.action.setText('开始');
    }
});

window.closeAll.click(()=>{
    if(fuck.isAlive()){
        fuck.interrupt();
    }
    engines.stopAll();
    toast("感谢本次使用");
});

window.action.longClick(()=>{
   window.setAdjustEnabled(!window.isAdjustEnabled());
   return true;
});

setInterval(()=>{}, 1000);

你可能感兴趣的:(AutoJs刷好策)