封装的一些函数新手拿来用吧

[复制链接]
查看6597 | 回复28 | 2021-10-22 01:29:38 | 显示全部楼层 |阅读模式
function 判断前台(包名)
        local pkg = 包名
        local ret = appIsFront(pkg)
        if ret == false then
                调试("包名不在前台")
                return true
        else
                调试("在前台")
                return false
        end
end
function 随机数(最大数,最小数)
        local r = rnd(最大数,最小数)
end
function 输入文字(内容)
        inputText(内容,true)
        setIme(false) --切换系统默认输入法
end
function 划动(x1,y1,x2,y2,s)
        swipe(x1,y1,x2,y2,s)
end

function 调试(内容)
        print(内容)
end
function 调试坐标(x,y)
        print(x,y)
end

function 显示(文字)
        toast(文字,0,0,12)
end
function 点击(x,y)
        tap(x,y)
        显示("点:",x,y)
end
function 找色(v,s)
        a=1
        x,y = findMultiColor (v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8])
        if x>-1 and y >-1 then
                if s==a then
                        点击(x,y)
                        调试坐标(x,y)
                        return x,y
                else
                        调试坐标(x,y)
                        return x,y
                end
        else
                return false
        end
end
function 比色(v)
        ret = cmpColorEx(v[1],v[2])
        if ret==1 then
                return true
        else
                return false
        end
end

function 找节点点击(v)
        local ret = nodeLib.findOne(v[2],v[3])
        if ret ~= nil then
                nodeLib.click(ret)
                return true
        else
                return false
        end
end
function 找节点(v)
        local ret = nodeLib.findOne(v[2],v[3])
        if ret ~= nil then
                return true
        else
                return false
        end
end
function 顺序找节点(v)
        local ret = nodeLib.findByIndex(v[1])
        if ret ~= nil then
                return true
        else
                return false
        end
end
function 顺序找节点点击(v)
        local ret = nodeLib.findByIndex(v[1])
        if ret ~= nil then
                nodeLib.click(ret)
                return true
        else
                return false
        end
end
function 屏幕分辨率(w,h)
        w,h = getDisplaySize()
        print(w,h)
       
end
function 找坐标(x1,y1,x2,y2)
       
        local r = ocrEx(x1,y1,x2,y2)
        local a,z = "41","66"
        if r ~= nil then
                local 坐标 = r[1].text
                local 查找逗号 = string.find(坐标, ":", 1)
                if 查找逗号 ~= nil then
                        local 分割坐标 = splitStr(坐标,":")
                        y =分割坐标[2]
                        x =分割坐标[1]
                        print(x)
                        print(y)
                        if x == a and y == z then
                                print("找到")
                                return true
                        else
                                print("没有找到")
                                return false
                        end
                end
        end
end
function 识别点击(x1,y1,x2,y2,x3,y3,文字)
       
        识别=ocrEx(x1,y1,x2,y2)
       
        if 识别==int then
                return false
        else
                print(识别[1].text)
        if 识别[1].text==文字 then
                        调试("找到")
                        点击(x3,y3)
                        return true
                else
                       
                        调试("没有找到")
                        return false
                end
               
        end
       
       
end
function 识别点击(x1,y1,x2,y2,文字)
       
        识别=ocrEx(x1,y1,x2,y2)
       
        if 识别==int then
                return false
        else
                print(识别[1].text)
        if 识别[1].text==文字 then
                        调试("找到")
                       
                        return true
                else
                       
                        调试("没有找到")
                        return false
                end
               
        end
       
       
end

回复

使用道具 举报

zklr00001 | 2021-10-23 06:49:51 | 显示全部楼层
回复

使用道具 举报

skyfloor | 2021-10-23 23:38:02 | 显示全部楼层
学习写法
回复

使用道具 举报

lcm2022 | 2021-11-19 22:24:16 | 显示全部楼层
学习学习
回复

使用道具 举报

mrqx520 | 2021-11-19 23:17:42 | 显示全部楼层
学习学习
回复

使用道具 举报

18091935689 | 2022-1-23 16:46:57 | 显示全部楼层
666666666666666666666
回复

使用道具 举报

wxy0627 | 2022-2-26 20:20:13 | 显示全部楼层
这个点击节点是不是直接可以用了?
回复

使用道具 举报

qq9451045 | 2022-2-28 23:12:25 | 显示全部楼层
666666666366

安卓脚本,苹果脚本
脚本定制接单;自动化操作;手动能完成的都能做;
Q: 9451045
回复

使用道具 举报

大猪猪在江湖 | 2022-3-1 08:56:29 | 显示全部楼层
这个好用
回复

使用道具 举报

smalon | 2022-3-1 10:35:41 | 显示全部楼层
调试和显示可以放在一起. 然后可以加个随机点击.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

7

主题

18

帖子

233

积分

中级会员

Rank: 3Rank: 3

积分
233
QQ