function xs(参数) console.println(3,参数) toast(参数) print(参数)end
function 开启日志窗口() local 屏幕X,屏幕Y = getDisplaySize() print("屏幕X="..屏幕X.." 屏幕Y="..屏幕Y) local 中心点X=math.floor(math.tointeger(屏幕X)*0.35) local 中心点Y=math.floor(math.tointeger(屏幕Y)*0.35) local 大小X=math.floor(math.tointeger(屏幕X)*0.65) local 大小Y=math.floor(math.tointeger(屏幕Y)*0.4) console.show() console.setTitle("脚本运行日志") console.clearLog() console.setPos(中心点X,中心点Y,大小X,大小Y) print("屏幕中心点X="..中心点X.." 屏幕中心点Y="..中心点Y)end
function 无障碍判断() local r = isAccessibilityServiceRun() --无障碍服务是否开启 if r then xs("无障碍服务开启了") else for i=1,5 do xs("软件无障碍服务未开启请手动开启!") end exitScript() endendfunction 获取房源位置() local 局部节点={ 位置信息_兄弟节点={text="O1CN01mUYqI91hQAOHRsmBQ_!!6000000004271-2-tps-13-24.png_"}, 第二种位置信息_兄弟节点={text="O1CN01dButtB20MwHglYMeb_!!6000000006836-2-tps-28-30.png_"}, } local ret = nodeLib.findPreNode(局部节点.位置信息_兄弟节点,false) if ret ~= nil then xs("一类卡片") xs("房源位置:"..ret.text) print(ret.text) return ret.text else xs("二类卡片") local ret = nodeLib.findNextNode(局部节点.第二种位置信息_兄弟节点,false) if ret ~= nil then xs("房源位置:"..ret.text) print(ret.text) return ret.text else return "我是未知滴" end endend
function 获取用户ID() local 局部节点={ 用户昵称父节点={id="com.taobao.alihouse.broker:id/main_title_item"} } local ret = nodeLib.findChildNodes(局部节点.用户昵称父节点,false) if ret ~= nil then xs("用户ID:"..ret[1].text) return ret[1].text else return false end end
function 获取用户消息() local 对方消息={} local 索引=0 local ret = nodeLib.findAll({id="com.taobao.alihouse.broker:id/chat_msg_item_wrapper"},false) if ret ~= nil then for i=1,#ret do local 父类判断=ret[i] local r = nodeLib.findInNode(父类判断,{id="com.taobao.alihouse.broker:id/tv_user_name"},true,true) if r~= nil then local 内容 = nodeLib.findInNode(父类判断,{id="com.taobao.alihouse.broker:id/tv_chat_text"},true,true) if 内容~=nil then 索引=索引+1 对方消息[索引]=(内容[1].text) end end end end return 对方消息end
function 判断是否有新消息出现(等待) local ret = nodeLib.findChildNodes({class="android.widget.LinearLayout",index="3",package="com.taobao.alihouse.broker"},false) if #ret > 1 then for i=1,等待 do xs("进入消息前已等待:"..i.."S 目标等待时长:"..等待.."S") sleep(1000) end nodeLib.click(nodeLib.findOne(0,0,0,0,{class="android.view.View",index="1",level="23"},true)) return true else print("没有新消息") return false endend
function 消息发送(内容) nodeLib.matchOneAndInputText({id="com.taobao.alihouse.broker:id/msgcenter_panel_input_edit"},内容) sleep(1500) nodeLib.click(nodeLib.findOne(0,0,0,0,{text="发送"},true)) sleep(500)end
function 表内成员添加(表,昵称,地址) 表[昵称]=地址end
function 表匹配(表,ID) for i,k in pairs(表) do if i==ID then return k end end return nilendfunction 倒查表匹配(表,ID) for i,k in pairs(表) do local 匹配处理=splitStr(k,"---") if 匹配处理[2]== ID then return 匹配处理[1] end end return nilendfunction 地址链接匹配(待匹配表,待匹配地址) for i,k in pairs(待匹配表) do local 匹配处理=splitStr(k,"---") if string.find(待匹配地址, ".*"..匹配处理[1]..".*")~=nil then print(匹配处理[2]) return 匹配处理[2] end end return falseend
function 地址链接文档匹配(表,内容) for i,k in pairs(表) do local 匹配处理=splitStr(k,"---") if #匹配处理>1 then if string.find(内容, ".*"..匹配处理[1]..".*")~=nil then print(匹配处理[2]) return 匹配处理[2] end end end xs("文档匹配失败") return 表[2]end
function 消息表英数匹配(待匹配表) for i,k in pairs(待匹配表) do if 匹配英数消息(k)~=nil then xs(k) return k end end return nilend
function 匹配英数消息(内容) if string.find(内容, "[a-zA-Z0-9\\s][a-zA-Z0-9\\s][a-zA-Z0-9\\s][a-zA-Z0-9\\s][a-zA-Z0-9\\s]")~=nil then--匹配用户消息是否存在英数 return 内容 else return nil endend
function 获取链接内容(链接) local 临时存放={} local ret = httpGet(链接) cd=splitStr(ret,"\n") for i=1,#cd do 临时存放[i]=cd[i] end return 临时存放end
function 微信消息通知(token,标题,内容) post内容="token="..token.."&title="..标题.."&content="..内容.."&channel=webhook&webhook=xianyu" local post请求=httpPost("
http://www.pushplus.plus/send",post内容) xs("API通知回调:"..post请求) print(post请求)end
function 获取卡片内容() local ret = nodeLib.findOne(0,0,0,0,{text="租房.*"},true) if ret ~= nil then xs("已获取卡片内容信息:"..ret.text) return ret.text endend
function 检测usb链接() local ret = nodeLib.findOne(0,0,0,0,{text="传输文件"},true) if ret~=nil then toast("USB已链接选择传输文件") sleep(1000) nodeLib.click(ret) endend