发帖
充值
 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
28 3

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

源码分享 22775 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

使用道具 举报

2021-10-23 06:49:51
2021-10-23 23:38:02
学习写法
2021-11-19 22:24:16
学习学习
2021-11-19 23:17:42
学习学习
2022-1-23 16:46:57
666666666666666666666
2022-2-26 20:20:13
这个点击节点是不是直接可以用了?
2022-2-28 23:12:25
666666666366
这个好用
2022-3-1 10:35:41
调试和显示可以放在一起. 然后可以加个随机点击.
您需要登录后才可以回帖 立即登录
高级模式
123下一页
源码分享