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

效果图:

相关推荐
何盖(何松影)39 分钟前
Android T startingwindow使用总结
android
小李飞飞砖2 小时前
Android 依赖注入框架详解
android
SUNxuetian2 小时前
【Android Studio】升级AGP-8.6.1,Find Usage对Method失效的处理方法!
android·ide·gradle·android studio·安卓
阿华的代码王国2 小时前
【Android】搭配安卓环境及设备连接
android·java
__water3 小时前
RHA《Unity兼容AndroidStudio打Apk包》
android·unity·jdk·游戏引擎·sdk·打包·androidstudio
一起搞IT吧5 小时前
相机Camera日志实例分析之五:相机Camx【萌拍闪光灯后置拍照】单帧流程日志详解
android·图像处理·数码相机
浩浩乎@6 小时前
【openGLES】安卓端EGL的使用
android
Kotlin上海用户组7 小时前
Koin vs. Hilt——最流行的 Android DI 框架全方位对比
android·架构·kotlin
zzq19967 小时前
Android framework 开发者模式下,如何修改动画过度模式
android
木叶丸7 小时前
Flutter 生命周期完全指南
android·flutter·ios