Fail 发表于 2020-10-13 20:13:18

淘宝支付宝芭芭农场自动收集肥料源码【Lua】


运行环境:LuaBox/积木编程(软件自行百度下载,关键词:LuaBox 积木编程)
运行系统:安卓 5 以上,无需 ROOT
使用方法:复制代码 - 打开软件 - 新建脚本 - 粘贴代码 - 运行
开发环境:触动精灵编辑器 3.0



脚本功能:自动签到、自动领浏览任务、自动领取淘金币兑换肥料任务
脚本语言:Lua

脚本原理:
仍然是使用安卓系统的无障碍权限查找界面控件的属性,最近比较嫌,也写了好几个类似的脚本了,考虑出一期视频来说一下开发经验

脚本源码:

<b>for i = 1,10 do
local qiandao = widget.find({["text"]="去签到",["type"]="Button"})
if qiandao ~= nil then
    toast("签到")
    widget.click(qiandao)
    mSleep(3000)
else
    local lingqu = widget.find({["text"]="去领取",["type"]="Button"})
    if lingqu ~= nil then
      toast("签到")
      widget.click(lingqu)
      mSleep(3000)
    else
      local liulan = widget.find({["text"]="去浏览",["type"]="Button",["path"]="/FrameLayout/LinearLayout/FrameLayout/ViewGroup/FrameLayout/WebView/bb/WebView/View/View/View/View/View/View/View/View/View/View/View/ListView/View/Button"})
      if liulan ~= nil then
            toast("开始浏览任务")
            widget.click(liulan)
            mSleep(3000)
            local t0 = os.time()
            mSleep(20000)
            local t1 = os.time()
            if t1 - t0 >= 20 then
                toast("任务完成,返回")
                keycode.back()
                mSleep(3000)
            end
      else
            local baba = widget.find({["text"]="芭芭农场",["path"]="/FrameLayout/LinearLayout/FrameLayout/LinearLayout/FrameLayout/FrameLayout/FrameLayout/RelativeLayout/LinearLayout/RecyclerView/FrameLayout/FrameLayout/RecyclerView/FrameLayout/TextView"})
            if baba ~= nil then
                x1,y1,x2,y2 = widget.region(baba)
                if x1 ~= -1 then
                  x = (x1+x2)/2
                  y = (y1+y2)/2
                  toast("打开芭芭农场,请手动点击【集肥料】按钮")
                  event.tap(x,y)
                  mSleep(3000)
                end
            end
      end
    endend</b>
页: [1]
查看完整版本: 淘宝支付宝芭芭农场自动收集肥料源码【Lua】