autojs 漂亮ui界面4

普通交流群698307198欢迎加入v群,和各位大神一同交流
免责声明:本博客提供的所有内容仅供学习、分享与交流,我们不保证内容的正确性。通过使用本博客内容随之而来的问题与本博客无关。当使用本博客代码时,代表你已接受本博客的免责声明

正文部分

效果图

在这里插入图片描述
在这里插入图片描述

已经对界面进行脱敏处理,只供学习.

"ui";
const storage = storages.create("Coolxx");

const isShow = storage.get("show",false)
const loopNum = storage.get("loopNum",100)
const sleepTime = storage.get("sleepTime",10)
const isVip = storage.get("isVip",false)
const playName = storage.get("playName","")
const playlists = storage.get("playlists","")
const isAnti = storage.get("anti",true)
const model = storage.get("model",0)

ui.statusBarColor("#1495E7")
ui.layout(
    <frame>
            <vertical>
                <appbar>
                    <toolbar id="toolbar" bg="#1495E7"  title="xx助手"></toolbar>
                </appbar>
                <ScrollView>
                <vertical>
                    <card w="*" h="70" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                        <horizontal gravity="center_vertical">
                            <View bg="#1495E7" h="*" w="5"/>
                            <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                <horizontal>
                                    <Switch id="autoService" text="无障碍服务" checked="{{auto.service != null}}" padding="8 8 8 8" textSize="14"/>
                                    <Switch id="isShow" text="悬浮窗" checked="{{isShow}}" padding="8 8 8 8" textSize="14"/>
                                </horizontal>
                            </vertical>
                        </horizontal>
                    </card>
                    <card w="*" h="270" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                        <horizontal gravity="center_vertical">
                            <View bg="#1495E7" h="*" w="5"/>
                            <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                <horizontal id="play"><text text="歌单名称"/><input w="*" hint="指定歌单模式该值必填" id="playlists"  text="{{playlists}}" /></horizontal>
                                <horizontal id="play"><text text="歌曲名称"/><input w="*" hint="搜索运行模式该值必填" id="playName"  text="{{playName}}" /></horizontal>
                                <horizontal><text text="循环次数"/><input w="*" id="loopNum" inputType="number" text="{{loopNum}}" /></horizontal>
                                <horizontal><text text="切歌间隔"/><input w="*" id="sleepTime"  inputType="number" text="{{sleepTime}}" /></horizontal>
                                <horizontal>
                                    <text text="是否下载"/><Switch id="isVip" padding="8 8 8 8" textSize="12" checked="{{isVip}}"></Switch>
                                    <text text="防止封号"/><Switch id="isAnti" checked="{{isAnti}}" padding = "8 8 8 8" textSize="12"></Switch>
                                </horizontal>
                                <horizontal><text text="运行模式"/><spinner id="model" entries="播放界面运行|搜索运行|播放喜欢的音乐|指定歌单" ></spinner></horizontal>
                            </vertical>
                        </horizontal>
                    </card>
                    <card w="*" h="200" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                        <horizontal gravity="center_vertical">
                            <View bg="#1495E7" h="*" w="5"/>
                            <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                <horizontal padding="0 5"><text id="title" text="[是否下载] 是否下载刷量歌曲,开启后会影响切歌间隔" textSize="13sp" /></horizontal>
                                <horizontal padding="0 5"><text id="title" text="[切歌间隔] 播放单条音乐多久切换下一首,单位秒" textSize="13sp" /></horizontal>
                                <horizontal padding="0 5"><text id="title" text="[运行模式] 播放界面运行:循环播放当前播放歌曲,需进入xx播放界面" textSize="13sp" /></horizontal>
                                <horizontal padding="0 5"><text id="title" text="[运行模式] 搜索运行:循环播放搜索歌曲,由参数[歌曲名称]决定" textSize="13sp" /></horizontal>
                                <horizontal padding="0 5"><text id="title" text="[运行模式] 播放喜欢的音乐:循环播放xx歌单[我喜欢的音乐]" textSize="13sp" /></horizontal>  
                                <horizontal padding="0 5"><text id="title" text="[运行模式] 指定歌单:循环播放xx歌单,由参数[歌单名称]决定" textSize="13sp" /></horizontal>  
                            </vertical>
                        </horizontal>
                    </card>
                    <card visibility="gone" w="*" h="50" margin="10 5" cardCornerRadius="2dp" cardElevation="1dp" foreground="?selectableItemBackground">
                        <horizontal gravity="center_vertical">
                            <View bg="#1495E7" h="*" w="5"/>
                            <vertical padding="10 8" h="auto" w="0" layout_weight="1">
                                <horizontal padding="0 5"><text id="title" text="[xx助手] 软件版权联系作者:xacm02022" textColor="#1495E7" textSize="16sp" maxLines="1"/></horizontal>    
                            </vertical>
                        </horizontal>
                    </card>
                    <vertical padding="5">
                        <button id="save" style="Widget.AppCompat.Button.Colored" text="保存脚本设置"/>
                        <horizontal>
                            <button w="auto" id="inbtn" style="Widget.AppCompat.Button.Colored" text="查看激活信息"/>
                            <button text="激活" id="activate" w="auto" style="Widget.AppCompat.Button.Colored" />
                            <button w="*" id="start" style="Widget.AppCompat.Button.Colored" text="运行"/>
                        </horizontal>
                    </vertical>
                </vertical>
                </ScrollView>
            </vertical>
    </frame>
)
 ui.model.setSelection(model) 
/* 
//激活脚本
ui.activate.on("click", e => {
    activeScript()
})

ui.inbtn.on("click", e => {
    const privateKey = storage.get("privateKey",false);
    if(privateKey === false) {
        alert("系统提示","脚本未激活")
    }else {
        let over = storage.get("overdueDate");
        if(over == null) {
            alert("系统提示","激活码:"+privateKey+"\n过期时间:无期限")
        }else{
            alert("系统提示","激活码:"+privateKey+"\n过期时间:"+ formatDate(over)) 
        }
    }
})

ui.start.on("click", function() {
    if(startBtn) {
        startBtn.setChecked(true)
    }else {
        if(auto.service == null) {
            toast("请先开启无障碍服务!");
            return;
        }
        const privateKey = storage.get("privateKey",false);
        if(privateKey == false) {
            toastLog("脚本未激活!请先激活")
            return
        }
        if(updateConfig()) {
            main();
        }
    }
}) */

参考文章

.

所属软件

韶image.png

声明

部分内容来自网络
本教程仅用于学习, 禁止用于其他用途

QQ群

698307198
扫一扫二维码,加入群聊.QQ

在这里插入图片描述

说明:
本文提供的代码仅供参考。
有些地方可能在最新版本的Auto.js上面需要做修改,才能运行的.如果不理解,可以加群询问.

Auto.js简介
Auto.js是利用安卓系统的“辅助功能”实现类似于按键精灵,触摸精灵.懒人精灵等一样,可以通过代码模拟一系列界面动作的辅助工作。
而与“按键精灵”不同的是,它的模拟动作并不是简单的使用在界面定坐标点来实现,而是类似与win一般,找窗口句柄来实现的。通过控件点击可以实现全分辨率的模拟人工点击效果

Auto.js使用JavaScript作为脚本语言,目前使用Rhino 1.7.7.2作为脚本引擎,支持ES5与部分ES6特性。新的autojs pro9系列可以使用node.js开发

开发文档
Auto.js Pro开发文档:点击这里

文档尚在完善中,可能有文档描述和代码实际行为有出入的情况。

为什么要使用Auto.js Pro开发脚本,有什么特点?

吸引我使用Auto.js Pro的原因有很多。最主要的几个原因是:

  1. Auto.js Pro能开发免ROOT的安卓脚本 Auto.js Pro基于节点操作,能开发全分辨率的脚本,自动适配各种安卓机型
  2. 可以使用手机开发,这使得开发者更多,有更多代码可以参考学习.在此也欢迎加入九黎的vip群,目前已经收集或者开发了大概4000余代码,覆盖各个分类.
  3. Auto.js Pro丰富的UI组件,能自定义各种样式的安卓界面 Auto.js.并且可以使用原生xml
  4. Pro使用的javascript的语法比较优雅,代码可读性强 Auto.js Pro的命令库非常的丰富,接口比较多 Auto.js
  5. Pro脚本文件体积比较小。1000行的代码,打包后的apk文件只有3-5M,还没有广告
    相关教程
    点击这里看更多 Auto.js Pro教程
  • 2
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值