基于autojs的快手抖音多应用一起刷的脚本,多页面ui

1)运行实例截图

 

 

 

 

 

主要运行原理

autojs 是模拟人手点击等手机自动化软件。可用于制作自动化脚本。

1)主要是上划,加一些关键词判断(避免卡在一些“我知道了”页面上划不了)

2)复杂一点的地方是同时支持多个应用,多个页面的ui设计。部分的源代码展示如下,如需要全部代码,请留言或私信

上划代码很简单:

xishua_common.keeping_swipe = function(local_app_name,run_time,swipe_direction,swipe_time_min,swipe_time_max,swipe_time, click_back, click_words) {
    run_start_time = commonfunc.time_get_seconds()
    //获取当前时间
    commonfunc.log("将一直划动%d分钟", run_time)
    while(commonfunc.time_get_seconds() - run_start_time < run_time * 60) {//运行时间没有到
        if (commonfunc.app_get_current_app_name() == local_app_name) {
            xishua_common.error_handle(click_words) //此函数比较耗时,抖音极速版大概会有20秒左右
            if (swipe_direction == "上") {
                commonfunc.log("上划动")
                swipe(device.width * 0.52, device.height * 0.8, device.width * 0.48, device.height * 0.2, swipe_time)
            } else if (swipe_direction == "下"){
                commonfunc.log("下划动")
                swipe(device.width * 0.52, device.height * 0.2, device.width * 0.48, device.height * 0.8, swipe_time)
            } else if (swipe_direction == "左") {
                commonfunc.log("左划动")
                swipe(device.width * 0.8, device.height * 0.52, device.width * 0.2, device.height * 0.5, swipe_time)
            } else if (swipe_direction == "右") {
                commonfunc.log("右划动")
                swipe(device.width * 0.2, device.height * 0.52, device.width * 0.8, device.height * 0.5, swipe_time)
            } else {
                commonfunc.log("默认上划动")
                swipe(device.width * 0.52, device.height * 0.8, device.width * 0.48, device.height * 0.2, swipe_time)
            }
        }
        sleep_time = random(swipe_time_min, swipe_time_max)
        sleep(sleep_time * 1000)

        if (commonfunc.app_get_current_app_name() == local_app_name && click_back == true) {
            back()
            commonfunc.log("返回")
        } else {

        }
    }

    commonfunc.log(local_app_name+"运行时间到")

}

 

多ui页面代码如下:

"ui";
ui.layout(
    <drawer id="drawer">
        <vertical>
            <appbar>
                <toolbar bg="#FF5c50e6" id="toolbar" title="喜刷" paddingTop="2dp" h="auto" >
                    <button bg="#FF00CED1" id="start" layout_gravity="right" textColor="#ffffff" text="开始" style="Widget.AppCompat.Button.Borderless.Colored" w="auto" />
                </toolbar>
                <tabs id="tabs" />
            </appbar>
            <viewpager id="viewpager">
                <frame>
                 {/* 第一级 主页*/}    
                    <scroll>
                            <vertical>
                                <card>
                                <horizontal weightSum="4">
                                    <Switch id="autoService" text="无障碍服务" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="15sp" layout_weight="2"/><Switch id="floatWindowPermission" text="悬浮窗权限" checked="{{floaty.checkPermission() == true}}" padding="8 8 8 8" textSize="15sp" layout_weight="2"/>
                                </horizontal>
                                </card>
                                <card>
                                <horizontal id="global_setting_1" weightSum="4">
                                    <text text="每个应用运行多久时间"  layout_weight="1"/><input id="run_time" inputType="number"  hint="分钟" layout_weight="1"/><text text="循环次数"  layout_weight="1"/><input id="repeat_time" inputType="number"  hint="循环" layout_weight="1"/>
                                </horizontal>
                                </card>
                                <card>
                                <horizontal id="click_words" weightSum="2">
                                    <text text="要点击的关键词"  layout_weight="1"/><input id="jump_word"  hint="多个关键词以@号分隔" layout_weight="1"/>
                                </horizontal>
                                </card>
                                <card>
                                <horizontal id="global_setting_2" weightSum="4">
                                    <text text="划动间隔最小时间"layout_weight="1"/><input id="swipe_time_min" inputType="number"   hint="秒" layout_weight="1"/><text text="最大时间" layout_weight="1"/><input id="swipe_time_max" inputType="number"  hint="秒" layout_weight="1"/>
                                </horizontal>
                                </card>
                                <card>
                                <horizontal weightSum="4">
                                    <text text="关闭视频" layout_weight="1"/><checkbox id="shutdown_video" layout_weight="1"/><text text="关闭声音" layout_weight="1"/><checkbox id="shutdown_audio" layout_weight="1"/> 
                                </horizontal>
                                </card>    
                                <card>
                                <horizontal weightSum="4">
                                    <text id="usage" text="用法说明视频"   layout_weight="1"/> 
                                </horizontal>
                                </card>                             
                            </vertical>
                    </scroll> 
                </frame>
                <frame>
                 {/* 第二级 已支持应用*/}    
                    <scroll>
                            <vertical>
                            <card  id="app_card_0" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_0"/><text id="app_name_0" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_0"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>
                            <card  id="app_card_1" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_1"/><text id="app_name_1" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_1"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>  
                            <card  id="app_card_2" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_2"/><text id="app_name_2" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_2"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>  
                            <card id="app_card_3" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_3"/><text id="app_name_3" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_3"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>  
                            <card id="app_card_4"  w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_4"/><text id="app_name_4" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_4"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>  
                            <card id="app_card_5" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_5"/><text id="app_name_5" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_5"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>             
                            <card id="app_card_6" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_6"/><text id="app_name_6" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_6"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>  
                            <card id="app_card_7" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_7"/><text id="app_name_7" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_7"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>
                            <card id="app_card_8" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                <vertical>
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_8"/><text id="app_name_8" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_8"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                </vertical>
                            </card>        
                            <card  id="app_card_9" w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                                
                                <horizontal weightSum="4">
                                    <checkbox id="app_is_run_9"/><text id="app_name_9" text="第一个应用" layout_weight="1"/><text text="运行时间"  layout_weight="1"/><input id="app_run_time_9"  hint="分钟" layout_weight="1"/>
                                </horizontal>
                                
                            </card> 
                            </vertical>
                    </scroll> 
                </frame>
                <frame>
                 {/* 第三级 高级用户*/}    
                    <scroll>
                            <vertical>
                            <card  w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                            <vertical>
                            <horizontal weightSum="4">
                                <checkbox id="cust_app_is_run_0"/><input id="cust_app_name_0"  layout_weight="1"/><text text="运行时间" layout_weight="1" /><input id="cust_app_run_time_0" hint="分钟" layout_weight="1"/>
                            </horizontal>
                            <horizontal weightSum="6">
                                <text text="划动方向" layout_weight="1"/><input id="cust_app_direction_0"  hint="上下左右" layout_weight="1"/><text text="速度" layout_weight="1"/><input id="cust_app_speed_0"  hint="1到10" layout_weight="1"/><checkbox text="是否返回" id="cust_app_click_back_0"  layout_weight="1"/>
                            </horizontal>
                            </vertical>
                            </card>

                            <card  w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                            <vertical>
                            <horizontal weightSum="4">
                                <checkbox id="cust_app_is_run_1"/><input id="cust_app_name_1"  layout_weight="1"/><text text="运行时间" layout_weight="1" /><input id="cust_app_run_time_0" hint="分钟" layout_weight="1"/>
                            </horizontal>
                            <horizontal weightSum="6">
                                <text text="划动方向" layout_weight="1"/><input id="cust_app_direction_1"  hint="上下左右" layout_weight="1"/><text text="速度" layout_weight="1"/><input id="cust_app_speed_1"  hint="1到10" layout_weight="1"/><checkbox text="是否返回" id="cust_app_click_back_1"  layout_weight="1"/>
                            </horizontal>
                            </vertical>
                            </card>                             

                            <card  w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                            <vertical>
                            <horizontal weightSum="4">
                                <checkbox id="cust_app_is_run_2"/><input id="cust_app_name_2"  layout_weight="1"/><text text="运行时间" layout_weight="1" /><input id="cust_app_run_time_0" hint="分钟" layout_weight="1"/>
                            </horizontal>
                            <horizontal weightSum="6">
                                <text text="划动方向" layout_weight="1"/><input id="cust_app_direction_2"  hint="上下左右" layout_weight="1"/><text text="速度" layout_weight="1"/><input id="cust_app_speed_2"  hint="1到10" layout_weight="1"/><checkbox text="是否返回" id="cust_app_click_back_2"  layout_weight="1"/>
                            </horizontal>
                            </vertical>
                            </card>

                            <card  w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                            <vertical>
                            <horizontal weightSum="4">
                                <checkbox id="cust_app_is_run_3"/><input id="cust_app_name_3"  layout_weight="1"/><text text="运行时间" layout_weight="1" /><input id="cust_app_run_time_0" hint="分钟" layout_weight="1"/>
                            </horizontal>
                            <horizontal weightSum="6">
                                <text text="划动方向" layout_weight="1"/><input id="cust_app_direction_3"  hint="上下左右" layout_weight="1"/><text text="速度" layout_weight="1"/><input id="cust_app_speed_3"  hint="1到10" layout_weight="1"/><checkbox text="是否返回" id="cust_app_click_back_3"  layout_weight="1"/>
                            </horizontal>
                            </vertical>
                            </card>

                            <card  w="*" h="auto" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                            <vertical>
                            <horizontal weightSum="4">
                                <checkbox id="cust_app_is_run_4"/><input id="cust_app_name_4"  layout_weight="1"/><text text="运行时间" layout_weight="1" /><input id="cust_app_run_time_4" hint="分钟" layout_weight="1"/>
                            </horizontal>
                            <horizontal weightSum="6">
                                <text text="划动方向" layout_weight="1"/><input id="cust_app_direction_4"  hint="上下左右" layout_weight="1"/><text text="速度" layout_weight="1"/><input id="cust_app_speed_4"  hint="1到10" layout_weight="1"/><checkbox text="是否返回" id="cust_app_click_back_4"  layout_weight="1"/>
                            </horizontal>
                            </vertical>
                            </card>
                            </vertical>
                    </scroll> 
                </frame>

                <frame>
                 {/* 第四页 调试和帮助*/}    
                    <scroll>
                            <vertical>
                                
                            </vertical>
                    </scroll> 
                </frame>
            </viewpager>
        </vertical>
    </drawer>
    
)

每个支持的应用顺序执行,时间到后退出,进行下一个应用:

            i = 0
            while(i < run_supported_app_array.length) {
                commonfunc.log("运行"+run_supported_app_array[i].name)
                for (j = 0; j < supported_app_array.length; j++) {
                    if (run_supported_app_array[i].name == supported_app_array[j].name) {
                        //寻找到了默认的支持的应用,划动的速度是每次划动500ms
                        supported_app_array[j].script.watch_video(run_supported_app_array[i].run_time,
                            Number(swipe_time_min_val),Number(swipe_time_max_val),5*100,mute_audio,mute_video,jump_word_array)
                        break
                    }
                }
                commonfunc.log("结束"+run_supported_app_array[i].name)
                if (commonfunc.app_get_current_app_name() == run_supported_app_array[i].name) {
                    home()
                }
                sleep(2000)
                i = i + 1
            }

由于代码量比较大,贴出部分代码。

另外自己封装了一些常用函数在common.js。这样就能提高复用度。且不容易出错,需要引用的时候只需要执行:

commonfunc = require(PROJECT_ROOT + "common.js")

封装的函数代码有:

注释也写得比较清楚,可以大量减少开发时间

//等待某个符合条件的控件出现,不使用平台的waitfor和untilFind,是因为这两个操作是阻塞的。默认等待10s
common.widget_wait_timeout = function(selector_conditions, log_info, time) {
    if (!time) {
        time = 10000
    }
    find = selector_conditions.visibleToUser(true).findOne(time)
    //findOne返回控件或者null
    if (find) {
        if (log_info)
            common.log("等到了" + log_info)
        return find
        //返回控件,方便后续操作
    } else {
        if (log_info)
            common.log("等不到" + log_info)
        return null
    }
}


//利用n的bounds转化为有超时时间的等待
//等待widget在某个父widget区域内出现
common.widget_wait_timeout_in_widget = function(n, selector_conditions, log_info, time) {
    b = n.bounds()
    v = common.widget_wait_timeout(selector_conditions.boundsInside(b.left,b.top,b.right,b.bottom), null, time)
    if (v) {
        if (log_info) {
            common.log("等到" + log_info)
        }
        return v
        //返回控件,方便后续操作
    } else {
        if (log_info) {
            common.log("无法等到" + log_info)
        }
        return null
    }
}

 

喜刷简介:

  1. 可以运行 快手极速版,抖音极速版,抖音火山版,微视等应用。
  2. 可以使手机显示黑屏画面,更加省电
  3. 也可以静音
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值