autojs 手游 脚本UI demo【仅供学习交流】

autojs 问道手游 脚本【仅供学习交流】
此处提供简易版悬浮窗demo
详情实现私聊博主

importClass(android.view.View);
var entries = "主线|师门";
auto.waitFor();
auto.setMode('normal');
requestScreenCapture();
var window = floaty.window(
    <vertical>
        <vertical bg="#7f8c8d" padding="0">
            <horizontal >
                <button id="center" textColor="green" textStyle="bold" margin="0" w="60">help</button>
                <spinner id="spinner" entries="{{entries}}" />
                <button id="btn" w="0" text="开始" layout_weight="0.2"> </button>
                <button id="exit" w="0" text="退出" layout_weight="0.2"></button>
            </horizontal>
        </vertical>
    </vertical>
);
window.setPosition(window.getX(), window.getY() + 200);

var x = 0,
    y = 0,
    windowX = 0,
    windowY = 0,
    isRuning = false,
    showConsole = false,
    isShowingAll = true;
window.center.setOnTouchListener(function (view, event) {
    switch (event.getAction()) {
        case event.ACTION_DOWN:
            x = event.getRawX();
            y = event.getRawY();
            windowX = window.getX();
            windowY = window.getY();
            break;
        case event.ACTION_MOVE:
            window.setPosition(windowX + (event.getRawX() - x), windowY + (event.getRawY() - y));
            break;
        case event.ACTION_UP:
            if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
                ui.run(function () {
                    if (isShowingAll) {
                        isShowingAll = false;
                        window.spinner.setVisibility(View.GONE);
                        window.btn.setVisibility(View.GONE);
                        window.exit.setVisibility(View.GONE);
                    } else {
                        isShowingAll = true;
                        window.spinner.setVisibility(View.VISIBLE);
                        window.btn.setVisibility(View.VISIBLE);
                        window.exit.setVisibility(View.VISIBLE);
                    }
                });
            }
            break;
    }
    return true;
});
window.exit.click(function(){
    window.close();
    engines.stopAll();
})
window.btn.click(function () {
    if (window.btn.getText() == '停止') {
        toast("停止任务");
        window.btn.setText("开始");
    } else {
        let r = window.spinner.getSelectedItem();
        toast("开始"+r);
        if(r=='主线'){
            threads.start(function(){
                runzx();
            })
        }else if(r='师门'){
            threads.start(function(){
                runsm();
            })
        }
        window.btn.setText("停止");
    }
});

function runzx(){
    while(true){
        //具体逻辑
        toast("主线运行中")
        sleep(1000);
    }
}

function runsm(){
    while(true){
    //具体逻辑
        toast("师门运行中")
        sleep(1000);
    }
}
setInterval(() => { }, 1000);
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值