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);