九局 - 自刷网课脚本
importClass(android.content.Context); importClass(android.provider.Settings); try { var Services = "org.autojs.autojs/com.stardust.autojs.core.accessibility.AccessibilityService:org.autojs.autojspro/com.stardust.autojs.core.accessibility.AccessibilityService"; var enabledServices = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES); //log('当前已启用的辅助服务\n', enabledServices); //var Services = enabledServices + ":org.autojs.autojspro/com.stardust.autojs.core.accessibility.AccessibilityService"; Settings.Secure.putString(context.getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, Services); Settings.Secure.putString(context.getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, '1'); log("成功开启AutoJS的辅助服务"); } catch (error) { toastLog("\n请确保已给予 WRITE_SECURE_SETTINGS 权限\n\n授权代码已复制,请使用adb工具连接手机执行(重启不失效)\n\n", error); } while(auto.service == null) sleep(15); //auto.waitFor();
threads.start(function () { images.requestScreenCapture(); }); while (!click("立即开始")) { }; sleep(1000); not_pause = true; function watch() { var tot = visibleToUser(true).depth(10).id("els_child_alisco_name").find();//com.tbc.android.jiuju:id/ let img = images.captureScreen(); tot.forEach(child => { var icon = child.parent().child(0); var b = icon.bounds(); img = images.captureScreen(); let vis = images.pixel(img, b.left + 25, b.top + 23); if (!colors.equals(vis, "#f25246")) { if (not_pause) { child.parent().click(); sleep(800); if (text("继续播放").exists()) { click("继续播放"); } } else { press(975, 388, 1); sleep(100); press(975, 388, 1); not_pause = true; } while (true) { let img2 = images.captureScreen(); vis = images.pixel(img2, b.left + 25, b.top + 23); if (colors.equals(vis, "#f25246")) break; }; } sleep(800); }) sleep(1000); } status = 1; running = false; var window = floaty.window( <frame> <button id="start" text="开始运行" w="90" h="40" /> </frame> ); window.exitOnClose(); window.start.click(function () { //跳到UI线程执行 if (!running) { running = true; if (status == 1) { t1 = threads.start(function () { // t1 线程不能访问UI 线程 running = false; status = 0; ui.post(function () { //让UI 线程去执行function window.start.setText("结束运行"); }, 0) while (true) { watch(); let p1 = visibleToUser(true).depth(10).id("els_child_alisco_name").findOne().bounds(); className("android.widget.ScrollView").depth(6).scrollDown(); sleep(1000); let p2 = visibleToUser(true).depth(10).id("els_child_alisco_name").findOne().bounds(); if (p1.centerY() == p2.centerY()) break; } toast("播放结束"); }); } else { not_pause = false; if (t1 && t1.isAlive()) t1.interrupt(); //判断线程是否创建 以及 线程是否活着 status = 1; window.start.setText("开始运行"); threads.start(function () { press(975, 388, 1); sleep(100); press(975, 388, 1); }); running = false; } } }); setInterval(() => { }, 1000);
东北日出西边雨 道是无情却有情