-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.lua
More file actions
762 lines (643 loc) · 17.7 KB
/
user.lua
File metadata and controls
762 lines (643 loc) · 17.7 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
--生成坐标.lua
-- 基础函数.lua
function Split(szFullString, szSeparator)
-- 字符串分割函数
-- szFullString 待分割字符串
-- szSeparator 分割字符
-- 返回一个 Table
local nFindSmain_tartIndex = 1
local nSplitIndex = 1
local nSplimain_tarray = {}
while true do
local nFindLastIndex = string.find(szFullString, szSeparator, nFindSmain_tartIndex)
if not nFindLastIndex then
nSplimain_tarray[nSplitIndex] = string.sub(szFullString, nFindSmain_tartIndex, string.len(szFullString))
break
end
nSplimain_tarray[nSplitIndex] = string.sub(szFullString, nFindSmain_tartIndex, nFindLastIndex - 1)
nFindSmain_tartIndex = nFindLastIndex + string.len(szSeparator)
nSplitIndex = nSplitIndex + 1
end
return nSplimain_tarray
end
function myRandom(n,m)
-- 构造自己的随机函数
-- 思路是用随机结果放大处理以后再置随机种子,然后随机
-- n,m 随机数起止,返回 N 到 M 之间的随机数
-- m 可用没有,如果没有,返回从1到 N 的随机数
if m == nil then
m=n
n=1
end
math.randomseed(os.clock()*math.random(9999999,99999999)+math.random(9999999,99999999));
return math.random(n,m)
end
function myRand(rnType,rnLen,rnUL)
-- 随机字符串函数
-- rnType 字符串样式,1、纯数字,2、手机号码,3、随机大小写字母,4、字母+数字,5、邮箱,6、16进制 7、生成62开头16位银行卡号
-- rnLen 字符a串长度
-- rnUL 字符串大小写(可选参数)1,字母全部大写,2,字母全部小写
-- 返回:相应字符串
local zmRan,HexRan,myrandS,rns
rnLen=rnLen or 1
rnUL=rnUL or 3
rns=rns or 0
rns=rns+1
zmRan={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}
HexRan={"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","A","B","C","D","E","F"}
myrandS=""
--myRandomseed(rns..tostring(os.time()):reverse():sub(1, 6))
if rnType==1 then
--生成纯数字
myrandS=myRandom(9)
for r1=1,rnLen-1 do
myrandS=myrandS..myRandom(0,9)
end
elseif rnType==2 then
--生成13开头和15开头的手机号
local mheader={"13","15","18"}
myrandS=mheader[myRandom(#mheader)]
for r1=1,9 do
myrandS=myrandS..myRandom(0,9)
end
elseif rnType==3 then
--生成大小写随机字母
for r1=1,rnLen do
myrandS=myrandS..zmRan[myRandom(52)]
end
elseif rnType==4 or rnType==5 then
--rnType==4的时候,生成前2到5位是字母,后面是数字的字母+数字字符串组合
--rnType==5的时候,把==4得到的字符串后面加邮箱地址
local rn3=myRandom(2,5)
for r1=1,rn3 do
myrandS=myrandS..zmRan[myRandom(52)]
end
for r1=1,rnLen-rn3 do
myrandS=myrandS..myRandom(0,9)
end
if rnType==5 then
local mailheader={"@qq.com","@hotmail.com","@sohu.com"}
myrandS=myrandS..mailheader[myRandom(#mailheader)]
end
elseif rnType==6 then
--生成16进制
myrandS=HexRan[myRandom(2,22)]
for r1=1,rnLen-1 do
myrandS=myrandS..HexRan[myRandom(22)]
end
elseif rnType == 7 then
--生成62开头16位银行卡号
myrandS="62"
for r1=1,14 do
myrandS=myrandS..myRandom(0,9)
end
end
if rnUL==1 then
return string.upper(myrandS)
--字母全部大写
elseif rnUL==2 then
return string.lower(myrandS)
--字母全部小写
else
return myrandS
end
end
function click(x,y,z)
-- 适用于触动精灵点击函数
-- x,y 点击位置 x 坐标和 y 坐标
-- z 点击后停留时间(毫秒)
-- 返回:无返回
touchDown(1,x,y)
mSleep(100)
touchUp(1,x,y)
if z ~= nil then
mSleep(z)
end
end
function isColor(x,y,c1,wc)
-- 适用于触动精灵的找色函数
-- x,y 找色点的 x 坐标和 y 坐标
-- c1 要找的颜色
-- wc 找色精度
-- 返回值: 找到色返回 true,找不到返回 false
if wc == nil then
wc=0
end
r, g, b = getColorRGB(x, y);
local r1=math.modf(c1/65536);
local g1=math.modf(c1/256)%256;
local b1=c1%256;
if math.abs(r-r1)<=wc and math.abs(g-g1)<=wc and math.abs(b-b1)<=wc then
return true
else
return false
end
end
function delFile(path)
--删除文件
--参数说明:path为要删除文件的路径,支持*通配符。
os.execute("rm -rf "..path);
end
function newfolder(path)
--创建文件夹
-- 参数说明:path为要创建文件夹的路径。
-- 如要创建test文件夹,则输入:
-- newfolder("/User/Media/TouchSprite/lua/test");
os.execute("mkdir "..path);
end
function readFile(filePath,row,column,Separator)
-- filePath 文件路径 字符串
-- row 行 数字
-- column 列 数字
-- Separator 分割符 字符串 千万不要用 "-"
--[[
本函数使用说明:
首先把需要读取文件路径赋值给变量“filePath”
如:qqNumberFilePath = "/User/Media/TouchSprite/lua/magic/03配置.ini"
a=readFile(qqNumberFilePath,1,1)
a的值为,文件03配置.ini里面第一行,第一列的值
qqNumberFilePath 变量名可以随意
行和列也可以随意
这样就可以很简单的获取文件里的任意值,让代码的结构变简单
]]
local file=io.open(filePath,"r")
if not(file) then
return "文件不存在"
end
local currentLine=1
local ok = false;
for fileRow in file:lines() do
if currentLine == row then
fileRowArray=Split(fileRow,Separator)
ok=true
break
else
currentLine=currentLine+1
end
end
fileRow=nil
file:close()
file=nil
if ok == false then
-- 上面的 for 循环,如果执行了 break 那么必然 currentLine == row
-- 如果 currentLine ~= row 应该是文件的行数没有需要的行数多,文件被读完了一遍,还没到需要的行数,自然跳出了
-- 2015年08月27日 增加 ok 变量:只要是跳出的,ok 值必然为 true,非 true 必然是列完了整个文件,for 循环自然完成
-- 一念成佛,想不通的时候,换个思路解决问题
return "结a束"
end
if fileRowArray == "" then
return ""
else
return fileRowArray[column]
end
end
function writeFile(filePath,write_type,content)
-- 写文件函数
-- filePath 字符串 文件路径
-- write_type 字符串 写入方式 "w" 覆盖写入 "a" 追加写入
-- content 字符串 写入内容
local file=io.open(filePath,write_type);
file:write(content)
file:close()
file=nil
end
function getList(path)
-- 遍历文件函数
-- 参数说明:path为要列举文件的文件夹的路径。
-- 返回值:返回一个table。
-- 如要列举触动精灵lua文件夹下所有的脚本文件,则输入:
-- list = getList("/User/Media/TouchSprite/lua/");
local a = io.popen("ls "..path);
local f = {};
if a == nil then
dialog(path.."路径下没获取到文件",0)
return f
end
for l in a:lines() do
table.insert(f,l)
end
return f
end
function get_bid()
-- 显示包名函数
mSleep(5000)
bid = frontAppBid()
mSleep(1000)
dialog(bid,0)
end
function Preferences( ... )
-- 重置设置函数
--开始重置设置
runApp("com.apple.Preferences")
mSleep(4000)
closeApp("com.apple.Preferences")
mSleep(4000)
--重置 设置 完成
end
function get_iphone_type()
-- 获取运行设备分辨率及系统版
iphone_type=""
width, height = getScreenSize();
if width == 640 and height == 1136 then
--iPhone 5, 5S, iPod touch 5
dialog("设备是<iphone5系列>",1)
mSleep(1500)
iphone_type="iphone5"
elseif width == 640 and height == 960 then
--iPhone 4,4S, iPod touch 4
dialog("设备是<iphone4>",1)
mSleep(1500)
iphone_type="iphone4"
elseif width == 1242 and height == 2208 then
--iphone6p
dialog("设备是<iphone6p>",1)
mSleep(1500)
iphone_type="iphone6p"
elseif width == 750 and height == 1334 then
-- iphone6
dialog("设备是<iphone6>",1)
mSleep(1500)
iphone_type="iphone6"
elseif width == 320 and height == 480 then
--iPhone 非高分屏
elseif width == 768 and height == 1024 then
--iPad 1,2, mini 1
elseif width == 1536 and height == 2048 then
--iPad 3,4,5, mini 2
end
return iphone_type
end
function airModel_5()
-- 适用于 iphone5分辨率 飞行模式函数
runApp("com.apple.Preferences")
mSleep(3000)
color = getColor(526, 241);
if color == 0xffffff then
click(548,239)
mSleep(4000)
end
click(548,239)
mSleep(5000)
closeApp("com.apple.Preferences")
mSleep(1000)
end
function airModel_4(status)
-- 适用于 iphone4分辨率 分辨率函数
runApp("com.apple.Preferences")
mSleep(5000)
if status == "on" then
if isColor(537, 238, 0xffffff) then
--飞行模式关闭的正常联网状态
click(537, 238)--点击打开飞行模式
mSleep(6000)
for i=1,60 do
if isColor(530, 239, 0x4cd864) then
break
else
mSleep(1000)
end
end
end
end
if status == "off" then
if isColor(530, 239, 0x4cd864) then
--飞行模式 打开的状态
click(537, 238)--点击关闭 飞行模式
mSleep(1000*10)
for i=1,60 do
if isColor(537, 238, 0xffffff) or isColor(65, 223, 0x995900) then
--isColor(65, 223, 0x995900)出现未安装好 sim 卡提示
break
else
mSleep(1000)
end
end
if isColor(65, 223, 0x995900) then
--出现未安装好 sim 卡提示
click(321, 533)--点好
mSleep(1000)
end
end
end
if status == nil then
--打开再关闭飞行模式
click(537, 238)--点击打开飞行模式
mSleep(7000)
click(537, 238)--点击关闭飞行模式
mSleep(1000*10)
if isColor(65, 223, 0x995900) then
--出现未安装好 sim 卡提示
click(321, 533)--点好
mSleep(1000)
end
end
closeApp("com.apple.Preferences")
mSleep(2000)
end
function http_get(url)
-- 调用插件 http get 方式访问网络 函数
loadPlugin("NetworkTools")
local result = callPlugin("NetworkTools", "httpGet", url)
unloadPlugin("NetworkTools")
if result == "!HTTP GET ERROR" then
dialog("访问"..url.."失败,将重试",3)
mSleep(3000)
return http_get(url)
else
return result
end
end
function ftp_download(ftp_path,save_path)
-- ftp 下载函数
-- ftp_path 待下载文件路径
-- save_path本地保存路径
-- 下载成功返回 true 失败返回 fales
local sz = require("sz")
local ftp = sz.ftp
-- ftp_path="ftp://lua:lua@202.146.219.111/resource/open47.png"
-- save_path="/User/Media/TouchSprite/res/open47.png"
_, err = ftp.download(ftp_path,save_path)
if err then
dialog(ftp_path.."下载文件失败", 1);
mSleep(1000);
return false;
else
dialog(ftp_path.."文件已下载成功", 1)
mSleep(1000);
return true;
end
end
function vpn_5()
-- 重播 vpn
dialog("开始设置VPN", 1)
mSleep(1000)
openURL("prefs:root=General&path=VPN"); --打开VPN界面
for i=1,10 do
if isColor(21,83,0x007aff) then
mSleep(1000)
break
else
mSleep(1000)
end
end
-- 到vpn 设置界面
click(537,282,3000); -- 关闭
click(537,282,3000); -- 打开
for i=1,60 do
if isColor(194,293,0x000000) then
mSleep(1000)
else
mSleep(1000)
break
end
end
closeApp("com.apple.Preferences")
mSleep(2000)
--关闭设置完成
end
function vpn_4( ... )
runApp("com.apple.Preferences")
mSleep(5000)
mSleep(1000);
touchDown(1,10,900);
mSleep(1000);
for i=0,700,10 do
touchMove(1,10,900-i);
mSleep(20);
end
mSleep(1000);
touchUp(1,10,200);
mSleep(1000)
-- 开始找 通用
keepScreen(true);
y=0;
for i=130,950,6 do
if (isColor(34,i,0x34aadc,0)) then;
y=i-88
mSleep(1000);
break
end
end
keepScreen(false);
click(34,y,3000); -- 点通用
--滑动两次寻找VPN
for i=1,2 do
mSleep(1000);
touchDown(1,10,900);
mSleep(1000);
for i=0,700,10 do
touchMove(1,10,900-i);
mSleep(20);
end
mSleep(1000);
touchUp(1,10,200);
mSleep(1000)
end
click(61,678,3000)--点击VPN
if isColor(534,239,0x4cd864) then--vpn打开
click(534,239,2000)--点vpn开关 关闭
end
if isColor(535,242,0xffffff) then --vpn关闭
local times=0
while true do
times=times+1
if times == 10 then
break
dialog("vpn连接失败,请检查!",0)
dialog("退出脚本",0)
lua_exit()
end
click(535,242,1000)--点vpn开关-打开
for i=1,60 do
if isColor(534,239,0x4cd864) then
mSleep(1000)
-- 连接成功
break
elseif isColor(533,79,0x949494) then
-- 出现弹窗
click(318,559,1000); -- 好
break
else
mSleep(1000)
end
end
if isColor(534,239,0x4cd864) then
break
end
end
end
closeApp("com.apple.Preferences")
mSleep(2000)
end
--触动lua路径
-- "/User/Media/TouchSprite/lua/"
function get_Gps(city_str)
-- 获取城市坐标
-- 返回纬度 经度
-- city_str="北京,北京,北纬39.91667东经116.41667"
local i=0
while (true) do
-- 循环体
i=i+1
if i > 200 then
break
end
i_str=string.sub(city_str,i,i+5)
-- print(i_str)
if i_str == "北纬" then
N_start=i+6
end
if i_str == "东经" then
N_end=i-1
N_str=string.sub(city_str,N_start,N_end)
E_str=string.sub(city_str,i+6,i+13)
break
end
end
-- N_str="北纬"
-- E_str="东经"
print(N_str)
print(E_str)
N_num=tonumber(N_str)
E_num=tonumber(E_str)
return N_num,E_num
end
function function_name( ... )
--开始整理文件
--定义文件路径
gps_file_path="C:/Users/xiexianliang/Desktop/gps/gps.xml"
gps_new_file_path="C:/Users/xiexianliang/Desktop/gps/gps.txt"
province=""
city=""
country=""
longitude=""
latitude=""
i=0
while (true) do
i=i+1
row_str=readFile(gps_file_path,i,1,"分隔符")
if row_str == "结a束" then
break
end
row_str=string.gsub(row_str,"%s*","")
-- 开始获取 省份 名字
str=string.sub(row_str,2,9)
if str == "province" then
_,s=string.find(row_str,"name=\"")
e,_=string.find(row_str,"\"longitude")
province=string.sub(row_str,s+1,e-1)
end
-- 开始获取 市 名字
str=string.sub(row_str,2,5)
if str == "city" then
_,s=string.find(row_str,"name=\"")
e,_=string.find(row_str,"\"longitude")
city=string.sub(row_str,s+1,e-1)
end
-- 开始获取 市 精度
str=string.sub(row_str,2,5)
if str == "city" then
_,s=string.find(row_str,"longitude=\"")
e,_=string.find(row_str,"\"latitude")
longitude=string.sub(row_str,s+1,e-1)
end
-- 开始获取 市 维度
str=string.sub(row_str,2,5)
if str == "city" then
_,s=string.find(row_str,"latitude=\"")
-- e,_=string.find(row_str,"\">")
latitude=string.sub(row_str,s+1,-3)
end
--开始记录
if str == "city" then
content=province..","..city..",longitude,"..longitude..",latitude,"..latitude.."\n"
writeFile(gps_new_file_path,"a",content)
end
end
end
--city_str="北京,北京,北纬39.91667东经116.41667"
--city_str="安徽省,合肥,北纬31.86706东经117.29181"
--117.29181,31.867063
-- N_num,E_num=get_Gps(city_str)
-- --开始放大100000
-- N_num=N_num*10^5
-- E_num=E_num*10^5
-- --
-- print(N_num)
-- print(E_num)
-- print("~~~~~~~~~~~~~~~~~~~~~~~~")
-- for i=1,20 do
-- N_r=myRandom(-11998,11998);
-- E_r=myRandom(-22815,22815);
-- N=N_num+N_r
-- E=E_num+E_r
-- N=N/100000
-- E=E/100000
-- print(E..","..N)
-- end
print("开始")
gps_new_file_path="C:/Users/xiexianliang/Desktop/gps/gps.txt"
-- gps_new_file_path="/User/Media/TouchSprite/lua/gps/gps.txt"
cc_file_path="C:/Users/xiexianliang/Desktop/gps/cc.csv"
user_file_path="C:/Users/xiexianliang/Desktop/gps/user.csv"
server_file_path="C:/Users/xiexianliang/Desktop/gps/user-50/1.txt"
ii=0
id_num=10499
while (true) do
ii=ii+1
if readFile(gps_new_file_path,ii,1,",") == "结a束" then
break
end
--保存文件路径
if math.fmod(ii,50) == 0 then
server_file_path="C:/Users/xiexianliang/Desktop/gps/user-50/"..ii..".txt"
-- city_file_path="/User/Media/TouchSprite/lua/gps/city/"..file_name
end
--文件第一行
-- first_row_string=readFile(gps_new_file_path,ii,1,",")..","..readFile(gps_new_file_path,ii,2,",")
-- writeFile(city_file_path,"a",first_row_string.."\n")
-- print(city_file_path)
-- --经度
-- longitude=readFile(gps_new_file_path,ii,4,",")
-- longitude=tonumber(longitude)
-- --维度
-- latitude=readFile(gps_new_file_path,ii,6,",")
-- latitude=tonumber(latitude)
-- -- 开始放大10^6
-- longitude=longitude*10^6
-- latitude=latitude*10^6
-- 开始获取省份
province=readFile(gps_new_file_path,ii,1,",")..","
-- 开始获取市
city=readFile(gps_new_file_path,ii,2,",")..","
-- print(longitude)
-- print(latitude)
for i=1,350 do
id_num=id_num+1
c1=readFile(user_file_path,i,1,",")..","
c2=readFile(user_file_path,i,2,",")..","
c3=readFile(user_file_path,i,3,",")..","
-- c4=readFile(user_file_path,i,4,",")..","
-- c5=readFile(user_file_path,i,5,",")..","
c6=readFile(user_file_path,i,6,",")..","
c7=readFile(user_file_path,i,7,",")..","
c8=readFile(user_file_path,i,8,",")..","
c9=readFile(user_file_path,i,9,",")..","
c10=readFile(user_file_path,i,10,",")..","
c11=readFile(user_file_path,i,11,",")..","
c12=readFile(user_file_path,i,12,",")..","
c13=readFile(user_file_path,i,13,",")..","
c14=readFile(user_file_path,i,14,",")..","
c15=readFile(user_file_path,i,15,",")..","
c16=readFile(user_file_path,i,16,",")..","
c17=readFile(user_file_path,i,17,",")..","
c18=readFile(user_file_path,i,18,",")..","
c19=readFile(user_file_path,i,19,",")..","
c20=readFile(user_file_path,i,20,",")..","
c21=readFile(user_file_path,i,21,",")..","
row_str=id_num..","..c1..c2..c3..province..city..c6..c7..c8..c9..c10..c11..c12..c13..c14..c15..c16..c17..c18..c19..c20..c21.."\n"
writeFile(server_file_path,"a",row_str)
-- print(E..","..N)
end
end
print("结束")