首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >滴滴抢单脚本,全自动抢单辅助插件,用ocr检测距离价格【仅供学习参考】

滴滴抢单脚本,全自动抢单辅助插件,用ocr检测距离价格【仅供学习参考】

原创
作者头像
用户11697648
发布2025-06-12 16:01:25
发布2025-06-12 16:01:25
1.1K0
举报

下载地址:https://www.pan38.com/share.php?code=frdRj

声明:仅用于学习参考用

Auto.js脚本会持续检测界面中的价格和距离信息,当价格低于100元且距离小于5公里时自动右滑。需要根据实际界面元素调整id选择器和正则表达式。使用时请确保已开启无障碍服务。

代码语言:txt
复制

// Auto.js脚本:检测价格和距离,符合条件则右滑
auto.waitFor();

// 主循环
while(true) {
    // 获取当前界面文本内容
    let text = id("content").findOne(2000);
    if (!text) {
        console.log("未找到内容");
        continue;
    }
    
    // 提取价格和距离信息(根据实际界面调整正则)
    let priceMatch = text.text().match(/¥(\d+)/);
    let distanceMatch = text.text().match(/(\d+)km/);
    
    if (priceMatch && distanceMatch) {
        let price = parseInt(priceMatch[1]);
        let distance = parseInt(distanceMatch[1]);
        
        console.log("当前价格:", price, "距离:", distance);
        
        // 判断条件:价格低于100且距离小于5km
        if (price < 100 && distance < 5) {
            console.log("符合条件,执行右滑");
            // 右滑操作(根据实际界面调整坐标)
            swipe(device.width * 0.8, device.height / 2, 
                  device.width * 0.2, device.height / 2, 500);
            sleep(2000); // 滑动后等待
        }
    }
    
    sleep(3000); // 每次检测间隔
}

无障碍部分模块:

代码语言:txt
复制


function checkAccessibility() {
    let am = context.getSystemService(android.content.Context.ACCESSIBILITY_SERVICE);
    return am.isEnabled();
}
console.log("无障碍服务状态:" + checkAccessibility());

// 方法2:检测特定包名的无障碍服务
function isMyAccessibilityEnabled() {
    let am = context.getSystemService(android.content.Context.ACCESSIBILITY_SERVICE);
    let services = am.getEnabledAccessibilityServiceList(
        android.accessibilityservice.AccessibilityServiceInfo.FEEDBACK_GENERIC
    );
    for(let i=0; i<services.size(); i++) {
        if(services.get(i).getId().includes(context.getPackageName())) {
            return true;
        }
    }
    return false;
}
console.log("本应用无障碍服务状态:" + isMyAccessibilityEnabled());

价格判断以及UI部分:

代码语言:txt
复制

"ui";
// 主界面布局
ui.layout(
    <vertical padding="16">
        <appbar>
            <toolbar title="价格检测设置"/>
        </appbar>
        
        <horizontal gravity="center">
            <text text="当前价格:" textSize="16sp"/>
            <text id="currentPrice" text="未检测" textColor="red" textSize="16sp"/>
        </horizontal>

        <horizontal gravity="center_vertical" marginTop="16">
            <text text="目标价格:" textSize="16sp" marginRight="8"/>
            <input id="targetPrice" inputType="number" hint="输入目标价格" text="100"/>
        </horizontal>

        <horizontal gravity="center_vertical" marginTop="8">
            <text text="滑动距离:" textSize="16sp" marginRight="8"/>
            <input id="swipeDistance" inputType="number" hint="输入滑动距离(km)" text="5"/>
        </horizontal>

        <button id="btnStart" text="开始检测" marginTop="24"/>
        <button id="btnStop" text="停止" marginTop="8" enabled="false"/>
        
        <horizontal gravity="center" marginTop="16">
            <checkbox id="chkAutoSwipe" text="自动右滑" checked="true"/>
            <checkbox id="chkToast" text="显示提示" checked="true" marginLeft="16"/>
        </horizontal>
    </vertical>
);

// 变量定义
let running = false;
let detectionThread = null;

// 开始按钮事件
ui.btnStart.on("click", function(){
    if(!auto.service){
        toast("请先开启无障碍服务");
        return;
    }
    
    running = true;
    ui.btnStart.enabled = false;
    ui.btnStop.enabled = true;
    
    detectionThread = threads.start(function(){
        while(running){
            detectAndProcess();
            sleep(3000);
        }
    });
});

// 停止按钮事件
ui.btnStop.on("click", function(){
    running = false;
    if(detectionThread) detectionThread.interrupt();
    ui.btnStart.enabled = true;
    ui.btnStop.enabled = false;
});

// 价格检测处理函数
function detectAndProcess(){
    let priceElem = id("price").findOne(2000);
    let distanceElem = id("distance").findOne(2000);
    
    if(priceElem && distanceElem){
        let currentPrice = parseFloat(priceElem.text().replace(/[^\d.]/g, ""));
        let currentDist = parseFloat(distanceElem.text().match(/\d+/)[0]);
        
        ui.run(() => {
            ui.currentPrice.text = currentPrice + "元";
            ui.currentPrice.textColor = currentPrice < ui.targetPrice.text ? "#4CAF50" : "#F44336";
        });
        
        if(ui.chkToast.checked){
            toast("当前价格: " + currentPrice + "元, 距离: " + currentDist + "km");
        }
        
        // 条件判断
        if(currentPrice <= ui.targetPrice.text && 
           currentDist <= ui.swipeDistance.text &&
           ui.chkAutoSwipe.checked){
            swipeRight();
        }
    }
}

// 右滑操作
function swipeRight(){
    let width = device.width;
    let height = device.height;
    swipe(width * 0.8, height / 2, width * 0.2, height / 2, 500);
}

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档