autox.js 实现遍历微信聊天列表 并发送固定消息

1 怎么找到界面上的聊天item?

每个item左边都有一张图片,通过获取图片并判断图片的位置来确定是否是聊天item。

关键代码:

js 复制代码
 var iconList = className("android.widget.ImageView").find();
  
 for(var i =0;i<iconList.length;i++){
        var icon = iconList[i];

        var icon = iconList[i];
        var iconBottom = icon.bounds().bottom;
        var iconHeight = icon.bounds().height;
        var right = icon.bounds().right;

        if(right > deviceWidth / 4){
            continue;
           }
   
        if(iconBottom < topHeight || iconHeight < 50){
           continue;
        }

        if((icon.parent() != null && icon.parent().className() == "android.widget.RelativeLayout" )
        && (icon.parent().parent() != null && icon.parent().parent().className() == "android.widget.LinearLayout" )
        && (icon.parent().parent().parent() != null &&  icon.parent().parent().parent().className() == "android.widget.LinearLayout" )
        && (icon.parent().parent().parent().parent() != null && icon.parent().parent().parent().parent().className() == "android.widget.ListView" )
        ){
            var item = icon.parent().parent().parent();
            var itemWidth = item.bounds().width();
            var itemHeight = item.bounds().height();
            if(itemWidth < device.width * 0.9)continue;
            activeItemList.push(item)
        }
    }

2 怎么滑动保证不会多滑动或者少滑动

通过swipe操作,swipe操作可以指定滑动距离。

js 复制代码
 for(var i =0;i<activeItemList.length;i++){
    
            var item = activeItemList[i];
            var itemWidth = item.bounds().width();
            var itemHeight = item.bounds().height();
            var itemBototom = item.bounds().bottom;
            if(itemWidth < 900)continue;
            var eachItemHeight = itemHeight;
        
            item.click();
            console.log("=======itemClick====");
       
            openChatAndSend()
            sleep(200);
            console.log("=======itemBack");
            checkIsMainPage();
            var scrollHeight  = eachItemHeight;
            if(isFirstScroll){
                isFirstScroll = false;
                scrollHeight = itemBototom - topHeight;
            }
        
            swipe(device.width / 2, device.height / 2 , device.width / 2 , device.height/2 - scrollHeight, 100);
    
            if(maxIconBottom < item.bounds().bottom){
                maxIconBottom = item.bounds().bottom;
            }
    
           
        // }else {
        //     console.log("======jump333")
        // }
    }

3 怎么判断滑动到底部了。当滑动到底部的时候,最后一个item的Bottom是小于device.height的。可以用这个为依据。

js 复制代码
 if(maxIconBottom < device.height){
        isReachBottom = true
    }

4 怎么判断滑动到顶部?

这里取巧,只有滑动到顶部的时候plus_icon才能找到。

js 复制代码
function scrollToTop(listView){
    var topAddIcon = id("plus_icon").findOne(200);
    while(topAddIcon == null){
        listView.scrollBackward();
        topAddIcon = id("plus_icon").findOne(200);
    }
}

5 跳转到聊天界面,怎么输入文字。

找到输入框,然后settext

js 复制代码
    var enter = className("android.widget.EditText").findOne(400)

    if(enter == null){
        back()
        return;
    };
    enter.setText("😄")

6 怎么发送

js 复制代码
   var sendButton = className("android.widget.Button").text("发送").findOne(400);
//    if(sendButton != null){
//     sendButton.click()
//    }

7 怎么返回

这里一定要用Back() 不然会发现返回去之后,找不到聊天item了。

js 复制代码
back()

效果图:

相关推荐
奋飞安全36 分钟前
别被外壳骗了,那只是柔软的伪装 - 某小说App Token算法分析
android·逆向
这个杀手不太累1 小时前
Android 通过广播监听home键和任务键
android·广播·home键·任务键
MonkeyKing_sunyuhua1 小时前
python线程间怎么通信
android·网络·python
芦半山3 小时前
穿越二十年:Android Native 内存泄漏检测的进化之路
android
恋猫de小郭3 小时前
Flutter 在 iOS 26 模拟器跑不起来?其实很简单
android·前端·flutter
尤老师FPGA4 小时前
使用ZYNQ芯片和LVGL框架实现用户高刷新UI设计系列教程(第三十二讲)
android·java·ui
叫我龙翔4 小时前
【MySQL】从零开始了解数据库开发 --- 复合查询
android·mysql·数据库开发
Kapaseker4 小时前
Compose 中实现凸角、凹角、切角、尖角
android·kotlin
Erwinl5 小时前
android 开机启动 无线调试
android
此生只爱蛋5 小时前
mysql_store_result
android·adb