星空软件

 找回密码
 立即注册

触动精灵借用无障碍开发的一款美团抢单脚本,非常小巧

新库软件 | 2023-10-20 14:29:11 | 显示全部楼层 |阅读模式
触动精灵
名称(name): 抢单脚本
大小: 0 KB
开发者: 触动精灵
是否开源: 开源版
功能介绍: 自动抢单检测价格,自动滑动的一个效果,需要借助OCR插件
下面是源码,然后OCR插件我这里也给大家奉上吧
文件名:TomatoOCR.apk
已经过安全软件检测无毒,请您放心下载

============================================================================
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+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("editId1")
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)
for i=1,900000099999999999999990 do

  print("点击",i.."次")

tap(218,126700)

sleep(math.tointeger(shuaxin))

end
end

beginThread(thread_func,1)

--开始线程
  require "懒人综合插件"
for i=1,9999999999999999 do

console.println(3," 日志任务开始1:")
--local 坐标组={x1,y1,x2,y2,x3,y3,...}

--检测价格图标

local retA = findMultiColorAll(0,0,0,0,"F40000","-1|2|F40000|-2|6|F40303|-5|8|F62B2B|-3|9|F40101",0,0.9)
if retA ~= nil then

for i=1,#retA do
yanchidianji=9999999
基础=i
--console.println(3,#ret)
--  console.println(3,ret.x)
  snapShot("/storage/emulated/0/"..i..".png",retA.x+10,retA.y-30,kuan,retA.y+50)
  --这里就是进入文字识别

  local result1 = ocr.ocrFile("/storage/emulated/0/"..i..".png",type)

print(result1)

   local list=类_Json.解Json格式(result1)

  SearchString =list.words
   SearchChar = "."
   pos = utf8.inStr(0, SearchString, SearchChar)
   str = utf8.left(list.words, pos-1)
   print("内容1".. str)
   --找到了小数

if pos>0 then

console.println(3," 存在小数点")
str = utf8.left(list.words,pos-1)
console.println(3," 原始内容:"..list.words,pos-1)
print("内容"..str)

print(类_字符串.是否为纯数字(str)) -- true false
if 类_字符串.是否为纯数字(str)==true then
print(list.words.."是数字")

console.println(3," 是数字")

----------------------------是数字检测价格

if math.tointeger(str)>math.tointeger(1) then
print("准备抢单")
console.println(3," 准备抢单")
--检测滑动
console.println(3," 价格"..str)

console.println(3," 这是Y:"..retA.y)
local w,h = getDisplaySize()
print(w,h)

local retAh = findMultiColorAll(0,retA.y,w,h,"7F6517","4|2|806617|6|4|7F6617|5|9|7F6517|3|10|8D711A",0,0.9)

if retAh ~= nil then
console.println(3,"x"..retAh[1].x)

console.println(3,"y"..retA.y)

if retAh[1] ~= nil then
console.println(3,"不为空")
if retAh[1].y>retA.y then
console.println(3," 准备滑动")
print("正在滑动")

local r=无障碍_手势滑动({350,retAh[1].y,2000,retAh[1].y},150)
local r=无障碍_手势滑动({350,retAh[1].y,2000,retAh[1].y},150)
  console.println(3," 抢单了,延迟"..yanchi.."毫秒")
   sleep(math.tointeger(yanchi))

else
console.println(3," 未检测到滑动")

end

end

end

--检测滑动

else
print("价格不符合")
console.println(3," 价格不符合")

end

----------------------------是数字检测价格

else
print("不是数字")
console.println(3," 不是数字")

end

else

print("当前的不存在小数点")

console.println(3," 不是小数点")
console.println(3," 原始内容:"..list.words)

--不存在小数点的判断是否为数字

print(类_字符串.是否为纯数字(list.words)) -- true false
if 类_字符串.是否为纯数字(list.words)==true then
print(list.words.."不存在小说点的是数字")

console.println(3," 不存在小数点的是数字")

----------------------------是数字检测价格

if math.tointeger(list.words)>math.tointeger(1) then
print("准备抢单")
console.println(3," 准备抢单")
--检测滑动
console.println(3," 不存在小数点价格"..list.words)

console.println(3," 这是retA.y"..retA.y)
local ww,hh = getDisplaySize()
print(ww,hh)
console.println(3," w:"..ww)
local retAhh = findMultiColorAll(0,retA.y,ww,hh,"7F6517","4|2|806617|6|4|7F6617|5|9|7F6517|3|10|8D711A",0,0.9)

console.println(3,#retAhh)

if retAhh ~= nil then
console.println(3," 找到了第二单滑动")

if retAhh[1] ~= nil then

if retAhh[1].y>retA.y then
console.println(3," 准备滑动")
print("正在滑动")

local r=无障碍_手势滑动({350,retAhh[1].y,2000,retAhh[1].y},150)
local r=无障碍_手势滑动({350,retAhh[1].y,2000,retAhh[1].y},150)
  console.println(3," 抢单了,延迟"..yanchi.."毫秒")
   sleep(math.tointeger(yanchi))

else
console.println(3," 未检测到滑动")

end

end

end

if retAhh == nil then
console.println(3," 没找到小数点滑动")
console.println(3," 没找到小数点滑动")
end

--检测滑动

else
print("价格不符合")
console.println(3," 价格不符合")

end

----------------------------是数字检测价格

else
print("不是数字")
console.println(3," 不是数字")

end

--不存在小数点的判断是否为数字

--判断是否为数字

--判断是否为数字
end

--找到了小说

  ------------------------------------
  --这里判断价格

  --这里判断价格

end

end

console.println(3," 没有检测到图标")

-- tap(293,2024)

-- sleep(500)

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","元")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId1","最高价:")
ui.addEditText("星辰脚本","editId2","49")
ui.addTextView("星辰脚本","bq2","元")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId11","取货距离:")
ui.addEditText("星辰脚本","editId11","3")
ui.addTextView("星辰脚本","bq11","km")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId3","滑动值:")
ui.addEditText("星辰脚本","editId3","150")
ui.addTextView("星辰脚本","bq3","毫秒")
ui.newRow("星辰脚本","row1")
ui.addTextView("星辰脚本","tvId4","刷新值:")
ui.addEditText("星辰脚本","editId4","1000")
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)   




上一篇:按键精灵哔哩哔哩自动评论脚本,源代码分析,可二次开发
下一篇:按键精灵附近人快速打招呼脚本源码,速度快,回应高
回复

使用道具 举报

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

本版积分规则

全站声明【必看】|小黑屋|新库软件 |网站地图

GMT+8, 2024-4-28 17:54 , Processed in 0.067873 second(s), 25 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.