function 无障碍_手势滑动(坐标组,time) --数组:坐标点
if time==nil or time=="" then
time=3000
end
local gesture = Gesture:new()
local path = Path:new()
path:setStartTime(10)
path:setDurTime(time)
for i=1,#坐标组,2 do
path:addPoint(坐标组[i],坐标组[i+1])
end
gesture:addPath(path)
local r = gesture:dispatch()
local t=50+time
sleep(t)
return r ----true false
end
function onClick()
--print(ui.getText("editId1"))
zuidijia=ui.getText("editId2")
shuaxin=ui.getText("editId4")
yanchi=ui.getText("editId5")
local path = "/storage/emulated/0/TomatoOCR.apk"
print(fileExist(path))
if fileExist(path)==false then
extractAssets("滴滴打车.rc","/storage/emulated/0","*.apk")
toast("准备释放资源,请稍等7秒钟...",0,0,30)
print("准备释放资源,请稍等7秒钟...")
sleep(7000)
end
local r = isSnapshotServiceRun() --截图服务是否开启
if r then --截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图截图
print("截图服务开启了")
--确定开启了截图服务,准备运行核心代码
local r = isAccessibilityServiceRun() --无障碍服务是否开启
if r then
print("无障碍服务开启了")
toast("准备启动订单检测,请等待...",0,0,30)
ui.dismiss("星辰脚本")
runApp("com.vmos.pro")
sleep(3000)
print("开始检测")
local kuan,gao
kuan,gao = getDisplaySize()
print(kuan,gao)
console.show()
console.setPos(kuan/2,gao-kuan/2,kuan/2,kuan/2-200)
print("截图服务没有开启,请手动设置")
console.println(3," 日志任务开始1:")
import('java.io.File')
import('java.lang.*')
import('java.util.Arrays')
import('android.content.Context')
import('android.hardware.Sensor')
import('android.hardware.SensorEvent')
import('android.hardware.SensorEventListener')
import('android.hardware.SensorManager')
import('com.nx.assist.lua.LuaEngine')
local loader = LuaEngine.loadApk("/storage/emulated/0/TomatoOCR.apk")
local OCR = loader.loadClass("com.tomato.ocr.lr.OCRApi")
local ocr = OCR.init(LuaEngine.getContext())
local type = 2;
console.println(3," 开始加载自动刷新模块,需等待3秒钟")
sleep(3000)
--开始线程
local var = {
exit = true,
data = 0,
}
function thread_func(arg)
end
--开始线程
require "懒人综合插件"
for i=1,9999999999999999 do
--先检测是否存在订单
intX,intY = findMultiColor(0,0,0,0,"FC754A","-11|-3|FC754A|-17|5|FC754A|-4|12|FC754A|-2|23|FC754A|-17|21|FC754A",0,0.9)
if intX>-1 and intY>-1 then
--存在订单开始剪辑距离和全程
console.println(3," 准备剪辑全程")
snapShot("/storage/emulated/0/客户距离.png",641,1574,1009,1708)
local result1 = ocr.ocrFile("/storage/emulated/0/客户距离.png",type)
print(result1)
console.println(3,result1)
local list=类_Json.解Json格式(result1)
SearchString =list.words
console.println(3,SearchString)
len = utf8.length(SearchString)
print(len)
str = utf8.mid(SearchString,1,len-2)
print(str)
console.println(3,"全程距离为:"..str)
local ret = math.ceil(str)
print(ret)
console.println(3,"最终距离为:"..ret.."公里")
if math.tointeger(ret)>math.tointeger(zuidijia)then
console.println(3,"符合距离开始抢单")
--tap(100,100)
else
console.println(3,"距离不符合"..str)
end
--存在订单开始剪辑距离和全程
end
--先检测是否存在订单
end
--上面的循环体
else
print("无障碍服务没有开启")
toast("无障碍服务未开启,请找到开启",0,0,30)
import('java.lang.*')
import('android.content.Context')
import('com.nx.assist.lua.LuaEngine')
import('com.nx.assist.lua.IReqSnapshotServiceResult')
LuaEngine.requestAccessibilityService()
end
--确定开启了截图服务,准备运行核心代码
else
print("截图服务没有开启,请手动设置")
toast("截图服务没有开启,请手动允许",0,0,30)
--开启截图
import('java.lang.*')
import('android.content.Context')
import('com.nx.assist.lua.LuaEngine')
import('com.nx.assist.lua.IReqSnapshotServiceResult')
local cbReqSnapshot = IReqSnapshotServiceResult{
onResult = function(ret)
print(ret) --ret是true或者false true表示成功,false失败
end
}
if isSnapshotServiceRun() == false then
LuaEngine.requestSnapshotService(cbReqSnapshot)
sleep(5000)
end
--开启截图
end
toast("截图服务已开启,请继续点启动",0,0,30)
end
ui.newLayout("星辰脚本")
ui.addTextView("星辰脚本","tvId","客户到车:")
ui.addEditText("星辰脚本","editId1","10")
ui.addTextView("星辰脚本","bq1","km")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId1","全程距离:")
ui.addEditText("星辰脚本","editId2","30")
ui.addTextView("星辰脚本","bq2","km")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId3","滑动值:")
ui.addEditText("星辰脚本","editId3","150")
ui.addTextView("星辰脚本","bq3","毫秒")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId4","刷新值:")
ui.addEditText("星辰脚本","editId4","1500")
ui.addTextView("星辰脚本","bq4","毫秒")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId5","抢停值:")
ui.addEditText("星辰脚本","editId5","5000")
ui.addTextView("星辰脚本","bq5","毫秒")
ui.newRow("星辰脚本","row1")
ui.addButton("星辰脚本","btn1","点我启动【永久授权】", -1, 100)
ui.setOnClick("btn1","onClick()")
ui.show("星辰脚本")
ui.show("星辰脚本")
sleep(100000)