Evan
Evan - 认证专家

注册于 5年前

回答
310
文章
36
关注者
39

使用vscode或者控制中心或者爱思助手将 /var/touchelf/scripts/ 内录制的文件下载到电脑 在用上述工具上传至其他手机的脚本目录内

function main()
    socket = require('socket')
    math.randomseed(socket.gettime() * 10000); -- 随机种子
    cleanPhoto() -- 清空相册
    mSleep(1000)
    local f = "/var/touchelf/" --图片目录
    local tmp = "/var/touchelf/tmp.png" --缓存图片(无需修改)
    local list = exec(string.format( "find %s -name *.png", f)) --查找所有png图片
    local listTable = Split(list,'\n')
    table.remove(listTable)
    if #listTable > 0 then
        local pic = listTable[math.random(1,#listTable)]
        local picInfo = exec(string.format( "file %s", pic))
        logDebug(pic)
        logDebug(picInfo)
        local w,h = string.match(picInfo,", (%d+) x (%d+),")
        if w and h then 
            logDebug(w..":"..h)
            local resize = math.random(90,100) --随机缩放范围.自己修改
            w = math.ceil(w * resize / 100)
            h = math.ceil(h * resize / 100)
            logDebug(w..":"..h)
            exec(string.format( "cp %s %s", pic, tmp))
            mSleep(1000)
            imageResize(tmp,w,h) --图片缩放
            saveImageToAlbum(tmp)
        else
            logDebug("图片格式错误")
        end
    else 
        logDebug("文件夹内无图片")
    end
end

function exec(command)
    local res = io.popen(command);
    if res then
        local ret = res:read("*a");
        res:close();
        return ret;
    else
        return -1;
    end
end
function Split(szFullString, szSeparator)
    local nFindStartIndex = 1
    local nSplitIndex = 1
    local nSplitArray = {}
    while true do
       local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex)
       if not nFindLastIndex then
        nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString))
        break
       end
       nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, nFindLastIndex - 1)
       nFindStartIndex = nFindLastIndex + string.len(szSeparator)
       nSplitIndex = nSplitIndex + 1
    end
    return nSplitArray
end
function cleanPhoto()
    exec("rm -rf /private/var/mobile/Media/PhotoData/*")
    exec("rm -rf /private/var/mobile/Media/DCIM/*")
    appKill("com.apple.mobileslideshow")
end
function main()
    math.randomseed(tostring(os.time()):sub(5):reverse()); -- 随机种子
    cleanPhoto() -- 清空相册
    mSleep(1000)
    local f = "/var/touchelf/" --图片目录
    local list = exec(string.format( "find %s -name *.png", f))
    local listTable = Split(list,'\n')
    table.remove(listTable)
    if #listTable > 0 then
        local pic = listTable[math.random(1,#listTable)]
        local resize = math.random(100,200) --随机缩放范围.自己修改
        logDebug(pic)
        imageResize(pic,resize,resize) --图片缩放
        saveImageToAlbum(pic)
    else 
        logDebug("文件夹内无图片")
    end
end

触摸精灵菜单中的注销功能注销一下就行

function main()
    local smtp = require("socket.smtp")
    local mime = require("mime")
    local ltn12 = require("ltn12")
    local f = "/var/touchelf/img.png"
    snapshotScreen(f)
    mesgt = smtp.message{
        headers = {
            to = "54321@qq.com", --收件人
            subject = "邮件标题"
        },
        body = {
            [1] = {
                body = mime.eol(0, "邮件正文")
            },
            [2] = {
                headers = {
                    ["content-type"] = 'text/plain; name="img.png"',
                    ["content-disposition"] = 'attachment; filename="img.png"',
                    ["content-description"] = 'the send script\'s source',
                    ["content-transfer-encoding"] = "BASE64"
                },
                body = ltn12.source.chain(
                    ltn12.source.file(io.open(f, "r")), 
                    ltn12.filter.chain(
                        mime.encode("base64"),
                        mime.wrap()
                    )
                )
            },
        }
    }
    r,e = smtp.send{
        server = "smtp.qq.com",     --邮箱服务器
        user = "12345@qq.com",     --用户名
        password = "password",     --密码或授权码
        from = "<12345@qq.com>",   --发件人
        rcpt = {                    --发送列表
            "<12345@qq.com>"
        },
        source = mesgt              --发送内容
    }
    if r then 
        logDebug("ok")
    else
        logDebug(e)
    end
end

如果一次发送多个图片拷贝body下的[2]内容,添加[3],[4]即可.望采纳

网盘应该不可以.其他比如ftp服务器之类的根据服务器提供的接口发送.

只是识别数字的话用ocr就可以.如果数字太小需要放大+二值化处理,具体见http://www.touchelf.net/docs/touchelfOcr 最下面的例子

使用API接口里面的获取应用状态接口.详情见文档

#触摸精灵调用百度AI实现文字识别 这个文章是收费的.大概的流程就是用两个key 先获取到token.图片先用io.open读取后base64转码 再用urlEncode转码 然后 post 给百度的接口.

发布
问题