4lqedz 发表于 2024-11-2 15:19:41

「按键精灵安卓版」快速给你的脚本加上保留配置和加载配置


    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">大众</span>好,我是公众号3分钟学堂的郭立员。</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">给<span style="color: black;">大众</span>介绍一种给脚本快速添加「<span style="color: black;">保留</span>」和「读取」UI配置文件的<span style="color: black;">办法</span>,我公众号的老粉可能<span style="color: black;">晓得</span>怎么<span style="color: black;">保留</span>和读取界面配置,<span style="color: black;">由于</span>我之前写过两期<span style="color: black;">关联</span>的<span style="color: black;">文案</span>教程。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这一期<span style="color: black;">文案</span>教程<span style="color: black;">咱们</span>着重<span style="color: black;">表现</span>两个字“</span><span style="color: black;">快速</span>”,教<span style="color: black;">大众</span>写好模板下次直接给自己的脚本添加一下就行。</span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">效果展示</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">存储配置和加载配置</span></span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/cd398bbb50a749b7a563ed5c9e408588~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1729807744&amp;x-signature=CBIyQB46vpliwKaeU8QnN3dU2e4%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">往期原理介绍</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">回顾一下之前两期的原理啊~</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">办法</span>1:<span style="color: black;">经过</span>uip命令读取界面上的内容,<span style="color: black;">而后</span><span style="color: black;">根据</span>元素名<span style="color: black;">叫作</span>以键值对的形式(json)写入到文本里面,利用文本这个存储媒介实现<span style="color: black;">保留</span>和读取界面配置。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">办法</span>2:读取和写入界面配置文件来实现界面存储和加载。配置文件存储位置有2种<span style="color: black;">状况</span>~</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">【<span style="color: black;">状况</span>1】脚本调试<span style="color: black;">周期</span>,配置文件路径是:新版和老版按键助手路径<span style="color: black;">区别</span>。</span></span></p>/sdcard/MobileAnJian/<span style="color: black;">UIConfig</span>/ <span style="color: black;">//老版按键助手</span>
    /sdcard/MobileAnJianVip/<span style="color: black;">UIConfig</span>/ <span style="color: black;">//新版按键助手</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">【<span style="color: black;">状况</span>2】脚本打包后,配置文件路径是:</span></span></p>/<span style="color: black;">data</span>/<span style="color: black;">data</span>/<span style="color: black;">"&amp;包名&amp;"</span>/files/script.cfg<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这两类路径<span style="color: black;">必定</span>要区<span style="color: black;">掰开</span>,<span style="color: black;">不可</span>用混淆了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">往期这两种<span style="color: black;">办法</span>各有<span style="color: black;">坏处</span>端,<span style="color: black;">办法</span>1需要预先写好每一个输入框、多选框、下拉框的名<span style="color: black;">叫作</span>,<span style="color: black;">不可</span>随便修改,<span style="color: black;">倘若</span><span style="color: black;">已然</span>写好的脚本,就不适合用这个<span style="color: black;">办法</span>去写了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">办法</span>2的<span style="color: black;">坏处</span>端是我在脚本中写的读取和写入配置文件的,必须在运行脚本后生效,<span style="color: black;">保留</span>配置点一下运行脚本还好,<span style="color: black;">倘若</span>是加载配置就<span style="color: black;">显出</span>很麻烦了,加载完还要重启脚本<span style="color: black;">才可</span>看到界面上的内容变化。</span></span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">本期原理介绍</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这一期的原理是结合前两期的内容,</span><span style="color: black;">以<span style="color: black;">办法</span>1为<span style="color: black;">基本</span>,<span style="color: black;">经过</span><span style="color: black;">办法</span>2获取元素名<span style="color: black;">叫作</span>及类型,<span style="color: black;">处理</span><span style="color: black;">办法</span>1的缺陷</span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">下面分别说一下<span style="color: black;">保留</span>配置和读取配置</span></span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">保留</span>界面原理</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">①读取界面上“可修改”内容,<span style="color: black;">亦</span><span style="color: black;">便是</span>被存储到界面配置文件里面的,并不是所有的界面元素啊,这一点需要<span style="color: black;">重视</span>一下。“可修改”内容<span style="color: black;">包含</span>:输入框的内容、多选框<span style="color: black;">是不是</span>勾选、下拉框的选项。</span></span></p><span style="color: black;">UIP</span><span style="color: black;">.GetAttribute</span>(<span style="color: black;">"界面元素名<span style="color: black;">叫作</span>"</span>)<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这个命令的返回值是键值对的表(数组),<span style="color: black;">每一个</span>界面元素的键值对都是不<span style="color: black;">同样</span>的。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">输入框的内容</span></span></p><span style="color: black;">dim</span> ret=uip.GetAttribute(<span style="color: black;">"输入框1"</span>)
    showmessage ret[<span style="color: black;">"初始文本"</span>]<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">多选框<span style="color: black;">是不是</span>勾选</span></span></p><span style="color: black;">dim</span> ret=uip.GetAttribute(<span style="color: black;">"多选框1"</span>)
    showmessage ret[<span style="color: black;">"选中"</span>]<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">下拉框的选项编号</span></span></p><span style="color: black;">dim</span> ret=uip.GetAttribute(<span style="color: black;">"下拉框1"</span>)
    showmessage ret[<span style="color: black;">"初始选项"</span>]<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">倘若</span>你想深入<span style="color: black;">认识</span>的话,<span style="color: black;">能够</span><span style="color: black;">经过</span>下面的代码把所有的界面元素返回值都看一遍。</span></span></p><span style="color: black;"><span style="color: black;">Function</span> 按钮点击事件<span style="color: black;">()</span>
      <span style="color: black;">dim</span> <span style="color: black;">ret</span>=<span style="color: black;">uip</span>.<span style="color: black;">GetAttribute</span><span style="color: black;">(<span style="color: black;">"界面元素名<span style="color: black;">叫作</span>"</span>)</span>
      <span style="color: black;">Dim</span> <span style="color: black;">json</span>=<span style="color: black;">encode</span>.<span style="color: black;">tabletojson</span><span style="color: black;">(ret)</span>
      <span style="color: black;">showmessage</span> <span style="color: black;">json</span>
      <span style="color: black;">End</span> <span style="color: black;">Function</span></span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">②</span><span style="color: black;"><span style="color: black;">处理</span>获取界面元素名<span style="color: black;">叫作</span>的问题</span>,本文的高光点。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">以前在读取界面上内容时,都是要预先<span style="color: black;">晓得</span>界面上所有元素的名<span style="color: black;">叫作</span>,<span style="color: black;">例如</span>输入框有3个,<span style="color: black;">咱们</span><span style="color: black;">晓得</span>输入框1名<span style="color: black;">叫作</span>、输入框2名<span style="color: black;">叫作</span>、输入框3名<span style="color: black;">叫作</span>,<span style="color: black;">倘若</span><span style="color: black;">根据</span>循环去写名<span style="color: black;">叫作</span>还好,<span style="color: black;">能够</span><span style="color: black;">经过</span>计次循环的方式拼接名<span style="color: black;">叫作</span>,<span style="color: black;">例如</span></span><strong style="color: blue;"><span style="color: black;">输入框+序号。</span></strong></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">倘若</span>在编写脚本<span style="color: black;">起始</span>时就打算好了添加配置文件<span style="color: black;">保留</span>和加载功能,<span style="color: black;">能够</span>专门留言命名问题,<span style="color: black;">然则</span><span style="color: black;">咱们</span>在写脚本的时候都是<span style="color: black;">按照</span>需要随时可能会添加界面元素,<span style="color: black;">那样</span>这个<span style="color: black;">便是</span>个头疼的问题了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">那样</span>怎么<span style="color: black;">处理</span>呢?</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">读取脚本自己生成的界面配置文件</span></strong><span style="color: black;">,当<span style="color: black;">咱们</span>点击界面下方的<span style="color: black;">保留</span>按钮,在手机(模拟器)生成配置文件。</span></span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/4e5110c82d354932939491c518392647~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1729807744&amp;x-signature=45wg2N8v7SSVfIfszVgyR90A5FE%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">配置文件中<span style="color: black;">保留</span><span style="color: black;">咱们</span>想要的界面元素名<span style="color: black;">叫作</span>。</span></span></p>{<span style="color: black;">"下拉框1"</span>:<span style="color: black;">0</span>,<span style="color: black;">"多选框1"</span>:<span style="color: black;">true</span>,<span style="color: black;">"输入框1"</span>:<span style="color: black;">"你好"</span>}<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">分析到这里,<span style="color: black;">咱们</span>串联一下界面源码、界面展示内容、界面配置文件三者之间的关系,下面以输入框为例~</span></span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/b6f6202517c6439dafeae456e4baae99~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1729807744&amp;x-signature=ggfmbYNh40nUuS1bdquaajljsOk%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">经过</span>上图<span style="color: black;">能够</span>看到,界面上的元素名<span style="color: black;">叫作</span>,除了源码中有,在配置文件里面<span style="color: black;">亦</span>有,<span style="color: black;">那样</span>这就为<span style="color: black;">咱们</span><span style="color: black;">处理</span>获取界面元素名<span style="color: black;">叫作</span>问题<span style="color: black;">供给</span>了一个新的思路,</span><span style="color: black;">读取配置文件里面元素名<span style="color: black;">叫作</span></span>。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">第1</span>步:<span style="color: black;">运用</span>文本读取命令file.read,读取配置文件的内容,得到键值对的表。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">第二步:<span style="color: black;">针对</span>一个键值对的表,想要获取它的键名,最简单的<span style="color: black;">办法</span><span style="color: black;">便是</span>遍历数组了。</span></span></p>For Each k , v In table
    <span style="color: black;">//table是键值对</span>
    <span style="color: black;">//k是键值(key)</span>
    <span style="color: black;">//v是键值(value)</span>
    Next<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">第三步:获取到键名<span style="color: black;">亦</span><span style="color: black;">便是</span>元素名<span style="color: black;">叫作</span>,还有一个问题<span style="color: black;">便是</span>,怎么区分元素的类型。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">一般</span><span style="color: black;">来讲</span>,界面元素默认的命名方式是元素类型+编号:</span></span></p>输入框1、输入框2、输入框3…
    多选框1、多选框2、多选框3…
    下拉框1、下拉框2、下拉框3…<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">倘若</span><span style="color: black;">大众</span>都本本分分的<span style="color: black;">运用</span>这个默认名<span style="color: black;">叫作</span>,那<span style="color: black;">亦</span>还好,<span style="color: black;">然则</span><span style="color: black;">常常</span><span style="color: black;">大众</span>为了能够区分<span style="color: black;">每一个</span>元素的<span style="color: black;">功效</span>,会给它们修改名<span style="color: black;">叫作</span>。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">这般</span>一来就出问题了,当<span style="color: black;">咱们</span><span style="color: black;">经过</span>读取配置文件获取到一个元素名<span style="color: black;">叫作</span>,<span style="color: black;">而后</span>下一步就没法<span style="color: black;">经过</span>名<span style="color: black;">叫作</span>命名判断元素的类型了,到底是输入框、多选框还是下拉框。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">处理</span>这个问题我<span style="color: black;">供给</span>了<span style="color: black;">另一</span>一个思路:判断键值的类型。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">读取输入框<span style="color: black;">咱们</span>获取到内容是字符串类型,读取多选框<span style="color: black;">咱们</span>获取的true和false的布尔值类型,读取下拉框<span style="color: black;">咱们</span>获取到的是01234的数值类型。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">每一个界面元素的值都有自己<span style="color: black;">区别</span>的类型,<span style="color: black;">按照</span>键值类型反推元素类型,这个确实是一个可行的思路。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">当然到<span style="color: black;">这儿</span>我还是有一点担忧,<span style="color: black;">由于</span>我担心界面代码区不支持山海插件的tpye命令,<span style="color: black;">那样</span>就<span style="color: black;">没法</span>获取到数据类型了,好在测试了一下<span style="color: black;">能够</span>支持。</span></span></p><span style="color: black;">import</span> <span style="color: black;">"shanhai.lua"</span>
    <span style="color: black;">Function</span> <span style="color: black;">响应事件()</span>
    <span style="color: black;">Dim</span> <span style="color: black;">v=123</span>
    <span style="color: black;">showmessage</span> <span style="color: black;">shanhai.type(v)</span>
    <span style="color: black;">End</span> <span style="color: black;">Function</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">新建一个界面加上一个按钮的点击响应事件函数,测试<span style="color: black;">就可</span>。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">介绍3类返回值的写法:</span></span></p>字符串:<span style="color: black;">string</span>
    数值:<span style="color: black;">number</span>
    布尔值:<span style="color: black;">Boolean</span>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">到这一步<span style="color: black;">咱们</span><span style="color: black;">能够</span>把名<span style="color: black;">叫作</span>及对应的类型获取到了,<span style="color: black;">那样</span>就差最后一步写入配置了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">③把界面上的内容存储起来。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">之前的<span style="color: black;">过程</span><span style="color: black;">已然</span><span style="color: black;">能够</span>把所有的元素名<span style="color: black;">叫作</span>及类型获取到了,之后我就<span style="color: black;">能够</span>用</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">uip.GetAttribute 命令把界面所有内容都获取一遍,并以键值对的形式存入到一个新的文件中。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">这个文件的后缀<span style="color: black;">能够</span>是txt文本,cfg配置文件,<span style="color: black;">乃至</span>不写后缀都行。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">文件的路径,<span style="color: black;">倘若</span>是手机那就无<span style="color: black;">所说</span>了,<span style="color: black;">倘若</span>是模拟器想要实现多个模拟器共享配置文件就需要<span style="color: black;">重视</span>,必须放在共享文件夹里面,<span style="color: black;">倘若</span>不想共享配置文件,就需要放到其他非共享文件夹里面。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">当然不共享还有一个<span style="color: black;">办法</span>,<span style="color: black;">便是</span>文件名用imsi,imei之类的参数值,<span style="color: black;">这般</span><span style="color: black;">每一个</span>设备<span style="color: black;">亦</span>不<span style="color: black;">同样</span>,即使放到共享文件夹里面配置文件<span style="color: black;">亦</span>不共享的。</span></span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">保留</span>配置代码</h1>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/c8f3f9733329494c99849e4be54e19dc~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1729807744&amp;x-signature=%2BsiXHRbGMyipKre9DSPlNod3UXA%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">代码中的<span style="color: black;">有些</span>细节:</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">①</span><span style="color: black;">代码是脚本调试时的,它<span style="color: black;">运用</span>的是调试路径,并且那一串随机字符我模拟器里面的不是你的,必须要自己修改</span>。</span></p>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/b913564224b3466ebefea2373032a5f4~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1729807744&amp;x-signature=6PnkkoYhHR%2FV18rVGZBB6oSTBuo%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">看</span><span style="color: black;">生成文件的日期</span>找你自己<span style="color: black;">刚才</span>操作的界面配置文件。</span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">②界面配置文件缺失报错机制,首次<span style="color: black;">运用</span>脚本,<span style="color: black;">倘若</span>不点击<span style="color: black;">保留</span>按钮是不生成配置文件的,<span style="color: black;">因此</span>需要加一个提示信息。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">③存储配置不是直接复制生成的配置文件,而是遍历界面上所有的元素,<span style="color: black;">而后</span>存储起来,<span style="color: black;">原由</span>是修改完界面内容,<span style="color: black;">倘若</span>不点下方<span style="color: black;">保留</span>按钮,配置文件不会修改,直接复制配置文件,只能存储上次点击<span style="color: black;">保留</span>按钮时的界面内容。</span></span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">读取配置原理</h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">读取配置<span style="color: black;">触及</span>到的知识点,基本<span style="color: black;">保留</span>配置<span style="color: black;">同样</span>。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">第1</span>步:读取配置文件,<span style="color: black;">重视</span>是你存储的配置,不是自动生成的配置文件,路径别写错了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">第二步:转一下table,获取到元素的键值对。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">第三步:判断每一个元素的名<span style="color: black;">叫作</span>和值的类型,逐个修改界面元素。<span style="color: black;">运用</span>uip.SetAttribute命令。</span></span></p>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;">读取配置代码</h1>
    <div style="color: black; text-align: left; margin-bottom: 10px;"><img src="https://p3-sign.toutiaoimg.com/tos-cn-i-qvj2lq49k0/51ce58beec7740d1bee1f437fc5784be~noop.image?_iz=58558&amp;from=article.pc_detail&amp;lk3s=953192f4&amp;x-expires=1729807744&amp;x-signature=2A9eveWZoms9GO13RJ%2FmH193qNs%3D" style="width: 50%; margin-bottom: 20px;"></div>
    <h1 style="color: black; text-align: left; margin-bottom: 10px;"><span style="color: black;">运用</span><span style="color: black;">办法</span></h1>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;"><span style="color: black;">根据</span>我上面的讲解的内容,写好自己的模板,之后<span style="color: black;">倘若</span>想给自己的脚本添加此功能,<span style="color: black;">能够</span>先在界面源码中添加两个按钮,点击响应的名<span style="color: black;">叫作</span>写“存储配置”和“加载配置”,<span style="color: black;">而后</span>把函数代码放到界面代码区,就<span style="color: black;">能够</span><span style="color: black;">运用</span>了。</span></span></p>
    <p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">最后强调一点,首次<span style="color: black;">运用</span>脚本<span style="color: black;">必定</span>要先点一下自带的<span style="color: black;">保留</span>设置按钮。</span></span></p>




页: [1]
查看完整版本: 「按键精灵安卓版」快速给你的脚本加上保留配置和加载配置