-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathyyxlib.lua
More file actions
151 lines (125 loc) · 3.28 KB
/
Copy pathyyxlib.lua
File metadata and controls
151 lines (125 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
--[[
creator : yyx,
email:yanyuxuanonline@163.com/921832579.com
]]
DEBUG = true
--开启/关闭调试
function _setdebug(bool)
DEBUG = bool
end
--是否开启调试
function _isdebug()
return DEBUG
end
--调试输出,str消息,time停留时间
function _debug(contents,time)
if (time == nil) or (time == 0) then
time = 0
else
time = time
end
if _isdebug() then
toast(contents,time)
end
end
function _点击(xy)
if (type(xy[1]) == "table") then
for k,v in pairs(xy) do
_点击(v)
mSleep(v[3])
end
else
touchDown(xy[1],xy[2])
mSleep(50)
touchUp(xy[1], xy[2])
end
end
function _滑动(fromXY,pix,fx)
fx = fx or "down"
touchDown(fromXY[1],fromXY[2])
mSleep(50)
for i = 0, pix, 50 do
if (fx == "down")then
touchMove(fromXY[1], fromXY[2]+i);
elseif(fx == "up") then
touchMove(fromXY[1], fromXY[2]-i);
elseif(fx == "left") then
touchMove(fromXY[1]-i, fromXY[2]);
elseif (fx == "right")then
touchMove(fromXY[1]+i, fromXY[2]);
end
mSleep(50); --延迟
end
if (fx == "down")then
touchUp(fromXY[1], fromXY[2]+pix)
elseif(fx == "up") then
touchUp(fromXY[1], fromXY[2]-pix)
elseif(fx == "left") then
touchUp(fromXY[1]-pix, fromXY[2])
elseif (fx == "right")then
touchUp(fromXY[1]+pix, fromXY[2])
end
end
--多点找色
function _多点找色(Arr_colors,jd)
-- 默认找色精度90
jd = jd or 90
for _,val in pairs(Arr_colors) do
if (isColor(val[1],val[2],string.format("0x%x\n",val[3]),jd) == false) then
--_debug("未匹配到".."("..val[1]..","..val[2]..","..string.format("0x%x",val[3])..")")
return false
end
mSleep(20)
end
return true
end
--0x48739e
--多点找色并点击
function _多点找色并点击(Arr_colors,Arr_point,jd)
jd = jd or 90
if _多点找色(Arr_colors,jd) then
_点击(Arr_point)
end
end
--[[
example/例子:--该点可通过触动采色插件获取。
arrcolors = {["某特征页面的几个点"] = {{
{ 1367, 642, 0x4f4030},
{ 1363, 642, 0x615043},
{ 1354, 643, 0x554d47},
{ 1370, 657, 0xfffbdb},
{ 1407, 696, 0x9d753e},
{ 1403, 693, 0x291805},
{ 1415, 677, 0x361709},
}}}
arrpoint = {["某特征页面的几个点"] = {500,500}}
调用实现多点找色并点击arrpoint处!
_多点找色并点击(arrcolors.某特征页面的几个点,arrpoint.某特征页面的几个点)
]]
--区域多点找色
function _区域多点找色(colors,area,jd)
--默认精度98
jd = jd or 98
return findMultiColorInRegionFuzzy( string.format("0x%x\n",colors.color), colors.posandcolor, jd, area.X1, area.Y1, area.X2, area.Y2)
end
function _区域找图(path,area,jd)
jd = jd or 70
return findImageInRegionFuzzy(path, jd, area.X1, area.Y1, area.X2,area.Y2,1);
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