chumo123_
chumo123_

注册于 1年前

回答
2
文章
0
关注者
0

function main()

html = [[
  <!DOCTYPE html>

<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
</head>

<body>
<!-- 输入框设置-->
  <input id="a" type="text" value="坐标a"/>
  <input id="b" type="text" value="坐标b"/>
  <input id="c" type="text" value="坐标c"/>
  <input id="d" type="text" value="坐标d"/>
  <input id="e" type="text" value="坐标e"/>
  <input id="f" type="text" value="坐标f"/>
  <input id="g" type="text" value="坐标g"/>
  <input id="h" type="text" value="坐标h"/>

  <!-- 按钮区域,此处必须写,否则无法关闭动态UI-->
  <div style="padding-top: 10px">
      <!-- onOk()和onCancel()需要和JS内的function onOk() function onCancel()对应 -->
    <button onclick="onOk()">确定</button>
    <button onclick="onCancel()">取消</button>
  </div>

  <script>

    function onOk() {
      // 获取输入框内的值
      var data = {
        a: document.getElementById("a").value,
        b: document.getElementById("b").value,
        c: document.getElementById("c").value,
        d: document.getElementById("d").value,
        e: document.getElementById("e").value,
        f: document.getElementById("f").value,
        g: document.getElementById("g").value,
        h: document.getElementById("h").value,
      };

      // touchelf.return()为触摸内置函数, 此函数将关闭UI, 并将数据发送给sys.ui.show(), 作为其返回值
      touchelf.return(
        JSON.stringify({
          type: "ok",
          data: data,
        })
      );
    }

    function onCancel() {
      touchelf.return(JSON.stringify({ type: "cancel" }));
    }
  </script>
</body>

</html>

]]
--将html写入文件
flag,err = file.write("/var/touchelf/input.html",html);
res = sys.ui.show("/var/touchelf/input.html",100,100,400,500)
sys.log(res)
--json转table
t = codec.json.decode(res)
--用,分割 坐标填写方式  100,100
a = t.data.a:split('152,287')
b = t.data.b:split('372,297')
c = t.data.c:split('612,280')
d = t.data.d:split('160,555')
e = t.data.e:split('389,536')
f = t.data.f:split('616,555')
g = t.data.g:split('149,797')
h = t.data.h:split('373,804')
sys.log(a)
--点击坐标.延迟什么的自己加吧

while(i ~= 0xD5C631)
do
    i = screen.getColor(392,408);

    touch.tapRandom(a[1],a[2]);
    touch.tapRandom(b[1],b[2]);
    touch.tapRandom(c[1],c[2]);
    touch.tapRandom(d[1],d[2]);
    touch.tapRandom(e[1],e[2]);
    touch.tapRandom(f[1],f[2]);
    touch.tapRandom(g[1],g[2]);
    touch.tapRandom(h[1],h[2]);

    x, y = screen.findColor({0xF8DA87}, 90, 265, 316, 267, 318);--正常结束
    if x ~= -1 and y ~= -1 then
        touch.tapRandom(354, 1185, 15, 50, 1);--返回
        sys.sleep(500);
    end

    x, y = screen.findColor({0xE3AD52}, 90, 378, 1147, 380, 1149);--取消转盘
    if x ~= -1 and y ~= -1 then
        touch.tapRandom(355, 1147, 15, 50, 1);
        sys.sleep(500);
        touch.tapRandom(354, 1185, 15, 50, 1);--返回
        sys.sleep(500);
    end

    x, y = screen.findColor({0xF7D798}, 90, 436, 436, 438, 438);--取消宠物和商人
    if x ~= -1 and y ~= -1 then
        touch.tapRandom(515, 818, 15, 50, 1);
        sys.sleep(500);
        touch.tapRandom(354, 1185, 15, 50, 1);--返回
        sys.sleep(500);
    end
end

end

文档里有touch.slide函数,你试试设置两个啊
touch.slide(1)
touch.slide(2)

发布
问题