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

效果图:

相关推荐
fatiaozhang95273 小时前
创维智能融合终端SK-M424_S905L3芯片_2+8G_安卓9_线刷固件包
android·电视盒子·刷机固件·机顶盒刷机
来来走走4 小时前
Flutter开发 了解Scaffold
android·开发语言·flutter
哆啦A梦的口袋呀5 小时前
Android 底层实现基础
android
闻道且行之5 小时前
Android Studio下载及安装配置
android·ide·android studio
alexhilton6 小时前
初探Compose中的着色器RuntimeShader
android·kotlin·android jetpack
小墙程序员6 小时前
kotlin元编程(二)使用 Kotlin 来生成源代码
android·kotlin·android studio
小墙程序员6 小时前
kotlin元编程(一)一文理解 Kotlin 反射
android·kotlin·android studio
fatiaozhang95277 小时前
创维智能融合终端DT741_移动版_S905L3芯片_安卓9_线刷固件包
android·电视盒子·刷机固件·机顶盒刷机
小林学Android9 小时前
Android四大组件之Activity详解
android
搬砖不得颈椎病9 小时前
Jetpack DataStore vs SharedPreferences:现代Android数据存储方案对比
android