废话不多说直接上先上图片在代码,有问题可以加群(785554238) 群里有最新的版本,你也可以向作者提出你的需求,作者会根据你们的需求不断改进版本
1.自定义界面
下面是界面代码
欢迎界面
<窗口
宽度="600"
高度="600"
标题=" "
标签头高度="0"
配置文件="ui.config"
标签头背景="#00eeeeee"
标签头字体大小="16"
标签头选中字体颜色="#ffff3377"
标签头字体默认颜色="#ff3355ff">
<标签页 标题="界面1" 背景="#ffffffff">
<垂直布局 id="contain" 宽度="-1" 高度="-1" 对齐="居中" 背景="#002222222">
<垂直布局 id="div" 宽度="-1" 高度="150" 对齐="居中" 背景="#002222222">
<文本框 id="idLabel1" 文字颜色="#ff0099ff" 默认值="欢迎使用懒人精灵" 文字大小="30" 高度="-1" 宽度="-2" 边距="0,0,0,0"/>
<文本框 id="idLabel1" 默认值="作者懒人【学习交流群:785554238】" 文字颜色="#ff0099ff" 文字大小="20" 高度="-1" 宽度="-2" 边距="0,0,0,0"/>
</垂直布局>
</垂直布局>
</标签页>
</窗口>
悬浮窗入口配置界面
<窗口
宽度="600"
高度="600"
标题="挂机配置"
标签头高度="0"
配置文件="main.config"
标签头背景="#00eeeeee"
标签头字体大小="16"
标签头选中字体颜色="#ffff3377"
标签头字体默认颜色="#ff3355ff">
<标签页 标题="界面1" 背景="#ffffffff">
<垂直布局 id="contain" 宽度="-1" 高度="-1" 背景="#002222222">
<下拉框
id="idSelect1"
宽度="-1"
边距="10,5,10,5"
默认值="0">
<选项 文本="XXX游戏版本1"/>
<选项 文本="XXX游戏版本2"/>
<选项 文本="XXX游戏版本3"/>
</下拉框>
<水平布局 id="layer1" 宽度="-1" 高度="-2" 背景="#00000000">
<多选框
边距="10,20,10,10"
id="idtask"
布局方向="水平"
默认值="1@2@3">
<选项 文本="自动任务1"/>
<选项 文本="自动任务2"/>
<选项 文本="自动任务3"/>
<选项 文本="自动任务4"/>
<选项 文本="自动任务5"/>
<选项 文本="自动任务6"/>
</多选框>
</水平布局>
<水平布局 id="lay" 对齐="垂直居中" 宽度="-1" 高度="-2" 背景="#002222299" 边距="10,1,10,1">
<水平布局 id="layer2" 对齐="垂直居中" 宽度="-2" 高度="-2" 边距="1,1,20,1">
<文本框 id="idLabel1" 默认值="游戏配置【1】:" 文字大小="0" 高度="-2" 宽度="-2" 边距="0,0,0,0"/>
<输入框 id="idEdit1" 默认值="5" 文字大小="0" 宽度="-2" 高度="-2" 边距="0,0,0,0"/>
</水平布局>
<水平布局 id="layer2" 对齐="垂直居中" 宽度="-2" 高度="-2" 边距="1,1,20,1">
<文本框 id="idLabel1" 默认值="游戏配置【2】:" 文字大小="0" 高度="-2" 宽度="-2" 边距="0,0,0,0"/>
<输入框 id="idEdit2" 默认值="5" 文字大小="0" 宽度="-2" 高度="-2" 边距="0,0,0,0"/>
</水平布局>
</水平布局>
<水平布局 id="lay" 对齐="垂直居中" 宽度="-1" 高度="-2" 背景="#002222299" 边距="10,1,10,1">
<水平布局 id="layer2" 对齐="垂直居中" 宽度="-2" 高度="-2" 边距="1,1,20,1">
<文本框 id="idLabel1" 默认值="游戏配置【4】:" 文字大小="0" 高度="-2" 宽度="-2" 边距="0,0,0,0"/>
<输入框 id="idEdit3" 默认值="5" 文字大小="0" 宽度="-2" 高度="-2" 边距="0,0,0,0"/>
</水平布局>
<水平布局 id="layer2" 对齐="垂直居中" 宽度="-2" 高度="-2" 边距="1,1,20,1">
<文本框 id="idLabel1" 默认值="游戏配置【5】:" 文字大小="0" 高度="-2" 宽度="-2" 边距="0,0,0,0"/>
<输入框 id="idEdit4" 默认值="5" 文字大小="0" 宽度="-2" 高度="-2" 边距="0,0,0,0"/>
</水平布局>
</水平布局>
</垂直布局>
</标签页>
</窗口>
下面是脚本代码
Utils.lua
Utils = {}
ColorTable = {}
SwitchTable = {}
math.randomseed(os.time())
function rnd(start,begin)
return math.random(start,begin)
end
function IsMulitColor(arr)
if type(arr) == "table" and #arr == 9 then
if type(arr[1]) ~= "string"
or type(arr[2]) ~= "number"
or type(arr[3]) ~= "number"
or type(arr[4]) ~= "number"
or type(arr[4]) ~= "number"
or type(arr[6]) ~= "string"
or type(arr[7]) ~= "string"
or type(arr[8]) ~= "number"
or type(arr[9]) ~= "number" then
return false
end
return true
end
return false
end
function FindMColorEx(arr)
local x,y=-1,-1
pcall(function()
if arr == nil or
type(arr) ~= "table" then
return
end
if IsMulitColor(arr) then
x ,y = findMultiColor(arr[2],arr[3],arr[4],arr[5],arr[6],arr[7],arr[8],arr[9])
end
end)
return x,y
end
function GetTable(list)
local name,str = ""
if type(list) == "table" then
str = list[1]
name = list[2]
else
name = list
end
if str == nil then
str = ColorTable.ID
end
if ColorTable[str] ~= nil then
for k,v in pairs(ColorTable[str]) do
if v[1] == name then
return v;
end
end
end
return nil;
end
function Utils.SetTable(tbl)
ColorTable = tbl
end
function Utils.SetTableID(id)
ColorTable.ID = id
end
function Utils.Switch(str)
if SwitchTable[str] == nil then
SwitchTable[str] = true
else
SwitchTable[str] = not SwitchTable[str]
end
return SwitchTable[str]
end
function Utils.Msg(str)
toast(str,0,0,25)
end
function Utils.RndTap(X, Y, R) --随机点击 X:x坐标 Y:y坐标 R(可选):随机值
R = R or 5
R = R or 5
local r1 = rnd(math.abs(R)*-1, math.abs(R))
local r2 = rnd(math.abs(R)*-1, math.abs(R))
local r3 = rnd(100,500)
tap(X + r1, Y + r2)
sleep(r3)
end
function Utils.Split(Str, cutSymbol) --字符串分割
Str = tostring(Str)
cutSymbol = tostring(cutSymbol)
if (cutSymbol=='') then
return false
end
local pos,arr = 0, {}
for st,sp in function() return string.find(Str, cutSymbol, pos, true) end do
table.insert(arr, string.sub(Str, pos, st - 1))
pos = sp + 1
end
table.insert(arr, string.sub(Str, pos))
return arr
end
function Utils.Post(cb,delay,...) --延迟调用
if cb ~=nil and type(cb) == "function" then
delay = math.ceil(tonumber(delay) or 100)
setTimer(cb,delay,...)
end
end
function Utils.Find(...)
local Arr = {...}
local Rnd ,Str,isClick= 5,"",false
local iRet, sRet = pcall(function()
for i = 1,#Arr do
if type(Arr[i]) == "string" or type(Arr[i]) == "table" then
Str = Arr[i]
elseif type(Arr[i]) == "number" then
Rnd = Arr[i]
elseif type(Arr[i]) == "boolean" then
isClick = Arr[i]
end
end
end)
colorArr = GetTable(Str)
if colorArr == nil then
return false
end
x,y = FindMColorEx(colorArr)
if x >= 0 and y >= 0 then
print("pos:"..x..","..y)
if isClick then
Utils.RndTap(x,y,R)
end
return true
end
return false
end
function Utils.FindRet(...)
colorArr = GetTable(...)
if colorArr == nil then
return false
end
x,y = FindMColorEx(colorArr)
return x,y
end
function Utils.ZoomIn(x1,y1,x2,y2,R) --捏合
R = R or 5
local r = 3 --rnd(-1*R, R)
x1 = x1 + r
y1 = y1 + r
x2 = x2 + r
y2 = y2 + r
count = 2
centerX = (x1 + x2) / 2
centerY = (y1 + y2) / 2
stepX = (centerX - x1) / count
stepY = (centerY - y1) / count
touchDown(0,x1,y1)
sleep(10)
touchDown(1,x2,y2)
sleep(10)
for i=1,count do
x1 = math.ceil(x1 + stepX)
y1 = math.ceil(y1 + stepY)
x2 = math.ceil(x2 - stepX)
y2 = math.ceil(y2 - stepY)
touchMove(0,x1,y1)
sleep(10)
touchMove(1,x2,y2)
sleep(10)
end
touchUp(1)
sleep(10)
touchUp(0)
sleep(10)
end
function Utils.ZoomOut(x1,y1,x2,y2,R) --张开
R = R or 5
local r = 3 --rnd(-1*R, R)
x1 = x1 + r
y1 = y1 + r
x2 = x2 + r
y2 = y2 + r
count = 2
centerX = (x1 + x2) / 2
centerY = (y1 + y2) / 2
stepX = (centerX - x1) / count
stepY = (centerY - y1) / count
touchDown(0,centerX,centerY)
sleep(10)
touchDown(1,centerX,centerY)
sleep(10)
for i=1,count do
x1 = math.ceil(centerX - stepX)
y1 = math.ceil(centerY - stepY)
x2 = math.ceil(centerY + stepX)
y2 = math.ceil(centerY + stepY)
touchMove(0,x1,y1)
sleep(10)
touchMove(1,x2,y2)
sleep(10)
end
touchUp(1)
sleep(10)
touchUp(0)
sleep(10)
end
return Utils
main.lua
Utils = require "Utils"
local GAMEPKG = "xxxxxxxxxxx" --游戏包名
local w,h = getDisplaySize() --获取当前屏幕分辨率
if(w ~= 720 or h ~= 1280) then
Utils.Msg("目前仅支持720x1280分辨率\n当前分辩率["..w.."x"..h.."]")
sleep(10000)
exitScript()
else
Utils.Msg("当前屏幕分辩率:["..w.."x"..h.."]")
end
pcall(function()
local code,arr = showUI("悬浮窗界面.ui")
if arr then
local tasks = arr["idtask"]
end
end)
function BeginGame()
--开始游戏脚本任务
Utils.SetTableID("主界面")
if(Utils.Find("物体1")) then
else
Utils.Post(BeginGame,1000)
end
end
function KeepGameRun(pkg,n)--定时检测游戏是否处于前台,否则启动游戏
local delay = 1000
setControlBarPos(0.5,1)
if(appIsFront(pkg) == false) then
Utils.Msg("游戏加载中请稍等")
runApp(pkg)
delay = 1000
end
Utils.Post(KeepGameRun,delay,pkg)
end
Utils.SetTable(require("res"))
Utils.Post(BeginGame,2000) --延迟2秒触发开始脚本任务
Utils.Post(KeepGameRun,0,GAMEPKG)
while true do
sleep(100000)
end
3.res.lua
T={}
T["主界面"]={
{"物体1",200,200,600,1100,"C850D7","-30|-27|C741E0|-17|-25|D01BE2|-22|-31|D444E8|-31|-25|B01FD8|-17|-39|B8D8D4|-15|2|72B8B0|-5|14|88C2B8|12|13|B8DCD8",0,0.9},
{"物体2",200,200,600,1100,"48D8FF","-3|3|00B8F0|-2|6|00BCF2|3|11|20E6FF|8|8|43FEFF|7|2|48F2FF|1|4|00C3FF|11|-5|B8DCD6",0,0.95},
{"物体3",14,11,154,154,"2356AA","36|31|496BE3|8|82|2659B1|-14|33|FFFFFF|79|26|3B94DC|54|37|C9E0ED|60|94|3DA3EE",0,0.9},
{"物体4",161,17,233,89,"E1FEFF","12|-7|41AFF3|-21|26|8DCDFD|-42|27|84B0CF|20|22|1F69CF|-24|9|85C5F7",0,0.95},
{"物体5",424,5,717,354,"51545E","17|2|51545E|38|216|676B74|-41|6|504DE8|-47|22|5050E8|-36|16|FFFFFF|-41|220|E0E8E8",0,0.95},
}
return T