Guest User

Untitled

a guest
May 22nd, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.08 KB | None | 0 0
  1. Function endFunction(path, number)
  2. File.Write(path, number)
  3. EndScript
  4. End Function
  5.  
  6.  
  7. // 转账按钮界面的所有操作都包装在这个函数里
  8. Function transfer(jpgStorePath, pngStorePath, path, number, itemNumber)
  9. // 有没有头像的转账按钮位置不同,所以只能通过颜色来判断位置
  10. Dim transferPointX, transferPointY
  11. // 转账按钮界面的下边界
  12. Dim borderX, borderY
  13. // 转账按钮界面的性别颜色
  14.  
  15. Dim blueX, blueY, redX, redY, greenX, greenY, gender
  16. // 操作太过频繁的颜色
  17. Dim color7, color8
  18. // 账号存在异常的颜色
  19. Dim color4, color5
  20. // 操作上限颜色
  21. Dim color6
  22.  
  23. // 今天操作太频繁了,请改天再来
  24. color6=CmpColor(13, 1263, "626262", 1.0)
  25. If color6 > -1 Then
  26. TracePrint "今天操作太频繁了,请改天再来"
  27. SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-今日操作过多" & ".png"
  28. Tap 545, 751
  29. Call endFunction(path, number)
  30. End If
  31.  
  32. // 性别这里总共有三种颜色,绿色代表公司,粉红代表女,蓝色代表男
  33. // 蓝色
  34. FindColor 27, 585, 709, 1268, "FA9B25", 0, 1.0, blueX, blueY
  35. If blueX > -1 And blueY > -1 Then
  36. gender = "man"
  37. End If
  38. // 粉红色
  39. FindColor 27, 585, 709, 1268, "7E59F6", 0, 1.0, redX, redY
  40. If redX > -1 And redY > -1 Then
  41. gender = "woman"
  42. End If
  43. // 绿色
  44. FindColor 27, 585, 709, 1268, "A1B112", 0, 1.0, greenX, greenY
  45. If greenX > -1 And greenY > -1 Then
  46. gender = "company"
  47. End If
  48.  
  49. // 截图
  50. FindColor 27, 585, 709, 1268, "FFFFFF", 3, 1.0, borderX, borderY
  51. If borderX > -1 And borderY > -1 Then
  52. SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-" & gender & ".png", 27, 585, 709, borderY
  53. End If
  54.  
  55. // 点击:转账
  56. FindColor 15, 516, 40, 972, "E98E10", 0, 1.00, transferPointX, transferPointY
  57. TracePrint "transferPointX="&transferPointX&", transferPointY="&transferPointY
  58. If transferPointX > -1 And transferPointY > -1 Then
  59. TracePrint "transferPointX="&transferPointX&", transferPointY="&transferPointY
  60. Tap transferPointX, transferPointY
  61. Delay 1000
  62. End If
  63.  
  64. TracePrint "点击转账结束"
  65.  
  66. // 点击转账后,如果出现:操作太过频繁,请稍后再试
  67. color7 = CmpColor(13, 1263, "626262", 1.0)
  68. color8 = CmpColor(136, 574, "FFFFFF", 1.0)
  69. If color7 > -1 And color8 > -1 Then
  70. TracePrint "操作太频繁"
  71. SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-操作太过频繁" & ".png"
  72. Tap 548, 758
  73. Delay 1000
  74.  
  75. // 开始返回一层
  76. Tap 45, 97
  77. Delay 1000
  78.  
  79. Call endFunction(path, number)
  80. End If
  81.  
  82. TracePrint "操作太过频繁验证通过"
  83.  
  84. // 点击转账后,如果账号存在异常
  85. color4 = CmpColor(13, 1263, "626262", 1.0)
  86. color5 = CmpColor(168, 788, "FFFFFF", 1.0)
  87. If color4 > -1 And color5>-1 Then
  88. TracePrint "账号存在异常"
  89. SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-账号存在异常.png"
  90. Tap 548, 759
  91. Delay 1000
  92.  
  93. // 开始返回一层
  94. Tap 45, 97
  95. Delay 1000
  96. Else
  97. TracePrint "进入克服网络延迟"
  98. // 克服网络延迟,循环等待
  99. Dim b=0, returnColor
  100. While b = 0
  101. returnColor = CmpColor(547, 508, "FFFFFF", 1.0)
  102. If returnColor > -1 Then
  103. b=1
  104. End If
  105. Delay 1000
  106. Wend
  107.  
  108. // 有个提示:对方长时间没用支付宝,把这个提示叉掉
  109. Tap 682, 179
  110. Delay 1000
  111. TracePrint "叉掉点击验证"
  112. // 去掉点击验证
  113. Dim verifyX, verifyY
  114. FindColor 0, 236, 717, 258, "E98E10", 0, 1.0, verifyX, verifyY
  115. If verifyX > -1 And verifyY > -1 Then
  116. verifyX = verifyX - 2
  117. End If
  118. TracePrint "准备截图"
  119. SnapShot jpgStorePath & CStr(number) & "-" & CStr(itemNumber) & "-verify.jpg", 0, 224, verifyX, 273
  120.  
  121. // 开始返回(两层)
  122. Tap 35, 92
  123. Delay 1000
  124. Tap 35, 92
  125. Delay 1000
  126. TracePrint "返回两层"
  127. End If
  128. End Function
  129.  
  130. // 点击联系人电话
  131. Function clickPhone(jpgStorePath, pngStorePath, path, positionX, positionY, number)
  132.  
  133. TracePrint "进入clickPhone"
  134. TracePrint "positionX=" & positionX & ", positionY=" & positionY
  135. // 统计多少次之后出现:今日操作过多
  136. Dim count
  137.  
  138. // 如果有多条记录,就要进入选择界面
  139. Dim color1=CmpColor(13, 1263, "666666", 0.9)
  140. If color1 > -1 Then
  141. TracePrint "对应多个支付宝"
  142. // 截取选择界面
  143. Dim leftTopX, leftTopY, rightBottomX, rightBottomY, itemColor, isSwipe, barColor
  144. FindColor 0, 108, 694, 1259, "FFFFFF", 0, 1.00, leftTopX, leftTopY
  145. FindColor 0, 108, 694, 1259, "FFFFFF", 2, 1.00, rightBottomX, rightBottomY
  146. If leftTopX > -1 And leftTopY > -1 And rightBottomX > -1 And rightBottomY > -1 Then
  147. SnapShot pngStorePath & CStr(number) & "-itemList.png", leftTopX, leftTopY, rightBottomX, rightBottomY
  148.  
  149. // 有些手机号对应9个支付宝,而界面只能容纳7个,如果多于6个item,itemColor这个位置就是纯白色
  150. itemColor = CmpColor(669, 1263, "FFFFFF", 1.0)
  151. If itemColor > -1 Then
  152. isSwipe = True
  153. End If
  154. // 选择记录,每个记录的单元格是恒定不变的,大概是x:620,y:151
  155. Dim itemNumber, itemHeight, clickX, clickY
  156. itemNumber = (rightBottomY - leftTopY) / 151
  157. itemNumber = CInt(itemNumber)
  158. itemHeight = (rightBottomY - leftTopY) / itemNumber
  159. clickX = (rightBottomX - leftTopX) / 2
  160. TracePrint "itemNumber = " & itemNumber
  161. For i = 0 To itemNumber - 1 Step 1
  162. TracePrint "i = " & i
  163. // 如果不是第一次点,item界面是要重新点击才能获取的
  164. If Not (i = 0) Then
  165. TracePrint "如果不是第一次点,item界面是要重新点击才能获取的"
  166. Tap positionX, positionY
  167. Delay 1000
  168. End If
  169.  
  170. // 点击item
  171. clickY = leftTopY + i * itemHeight + itemHeight / 2
  172. Tap clickX, clickY
  173. Delay 1000
  174.  
  175. Call transfer(jpgStorePath, pngStorePath, path, number, i)
  176. count = count + 1
  177. Next
  178.  
  179. If isSwipe = True Then
  180. For i = 0 To 6 Step 1
  181. TracePrint "i = " & i+7
  182.  
  183. TracePrint "如果不是第一次点,item界面是要重新点击才能获取的"
  184. Tap positionX, positionY
  185. Delay 1000
  186.  
  187. Swipe 364, 1000, 364, 500
  188. Delay 1000
  189.  
  190. // 点击item
  191. clickY = leftTopY + i * itemHeight + itemHeight / 2
  192. Tap clickX, clickY
  193. Delay 1000
  194.  
  195. Call transfer(jpgStorePath, pngStorePath, path, number, i+7)
  196. count = count + 1
  197. Next
  198. End If
  199.  
  200. End If
  201. Else
  202. TracePrint "对应单个支付宝"
  203.  
  204. Call transfer(jpgStorePath, pngStorePath, path, number, 0)
  205. count = count + 1
  206.  
  207. End If
  208.  
  209. clickPhone=count
  210.  
  211. End Function
  212.  
  213. Function getNumber(path)
  214. Dim str, number
  215. str = File.Read(path)
  216. If IsNull(str) Then
  217. File.Write(path, 1)
  218. End If
  219. str = File.Read(path)
  220. number = CInt(str)
  221. TracePrint "number = " & number
  222. getNumber=number
  223. End Function
  224.  
  225. Function main()
  226. // 等待Toast消失
  227. Delay 3000
  228.  
  229. Dim pathRecordNumber="/sdcard/recordNumber.txt"
  230. Dim pathCountLimit="/sdcard/countLimit.txt"
  231. Dim jpgStorePath="/sdcard/dump/"
  232. Dim pngStorePath="/sdcard/dump/withoutOCR/"
  233. Dim isDirExist=Dir.Exist(jpgStorePath)
  234. TracePrint "jpg isDirExist = " & isDirExist
  235. If isDirExist=0 Then
  236. TracePrint "jpg路径不存在,创建之"
  237. Dir.Create (jpgStorePath)
  238. Else
  239. TracePrint "jpg存储路径已经存在"
  240. End If
  241. isDirExist = Dir.Exist(pngStorePath)
  242. TracePrint "png isDirExist = " & isDirExist
  243. If isDirExist=0 Then
  244. TracePrint "png路径不存在,创建之"
  245. Dir.Create (pngStorePath)
  246. Else
  247. TracePrint "png存储路径已经存在"
  248. End If
  249.  
  250.  
  251. Dim number=getNumber(pathRecordNumber)
  252. // 统计点多少次之后出现:今日操作过多
  253. Dim totalCount=getNumber(pathCountLimit)
  254.  
  255. // 每个联系人条目的高度是128
  256. Dim positionX, positionY, height, phoneListItemLeftTopX, phoneListItemLeftTopY
  257. height = 128
  258.  
  259. Dim a=1
  260. While a=1
  261.  
  262. // 根据滑动条检测是否滑动到底了
  263. // 如果滑动到底了,做完最后七个测试,然后退出大循环
  264. Dim color3 = CmpColor(710, 1273, "FFFFFF", 1.0)
  265. If color3 > -1 Then
  266. // do nothing
  267. Else
  268. a = 2
  269. TracePrint "滑动到底了"
  270. End If
  271.  
  272. // 由于swipe需要一定的时间,而滑动条的显示时间又过短,所以swipe之后的delay只用了0.1秒,可能会发生swipe没完成就开始点击的情况,所以这里补足延迟时间,让swipe的惯性滑动充分完成
  273. Delay 2000
  274.  
  275. // 找到可点击的位置
  276. FindColor 527, 224, 676, 600, "E98E10", 0, 1.0, positionX, positionY
  277. If positionX > -1 And positionY > -1 Then
  278. positionX = positionX - 100
  279. TracePrint "positionY = " & positionY
  280. // 截取列表界面
  281. SnapShot pngStorePath & CStr(number) & "-phoneList.png"
  282. // 每次点8个listItem
  283. For i = 0 To 7 Step 1
  284. Touch positionX, positionY, 2000
  285. // 找到条目的左上角
  286. FindColor 0, 227, 11, 1277, "DDDDDD", 0, 1.0, phoneListItemLeftTopX, phoneListItemLeftTopY
  287. If phoneListItemLeftTopX > -1 And phoneListItemLeftTopY > -1 Then
  288. // 截取联系人电话
  289. SnapShot jpgStorePath & CStr(number) & "-phoneNumber.jpg", 140, phoneListItemLeftTopY, 351, phoneListItemLeftTopY+59
  290. Delay 1000
  291.  
  292. totalCount = totalCount + clickPhone(jpgStorePath, pngStorePath, pathRecordNumber, positionX, positionY, number)
  293. TracePrint "totalCount = " & totalCount
  294. File.Write(pathCountLimit, totalCount)
  295. TracePrint number
  296. number = number + 1
  297. positionY = positionY + height
  298.  
  299. End If
  300. Next
  301. End If
  302.  
  303. Swipe 364, 732, 364, (732 - 400)
  304. Delay 100
  305.  
  306. Wend
  307.  
  308. File.Write(pathRecordNumber, number)
  309. End Function
  310.  
  311. Function touchNumber(number)
  312. If number = 1 Then
  313. Tap 200, 914
  314. ElseIf number = 2 Then
  315. Tap 359, 908
  316. ElseIf number = 3 Then
  317. Tap 522, 909
  318. ElseIf number = 4 Then
  319. Tap 199, 1014
  320. ElseIf number = 5 Then
  321. Tap 361, 1015
  322. ElseIf number = 6 Then
  323. Tap 520, 1013
  324. ElseIf number = 7 Then
  325. Tap 199, 1121
  326. ElseIf number = 8 Then
  327. Tap 361, 1122
  328. ElseIf number = 9 Then
  329. Tap 519, 1122
  330. ElseIf number = 0 Then
  331. Tap 361, 1222
  332. End If
  333. End Function
  334.  
  335. Function inputNumber(pageCount)
  336. TracePrint "开始输入数字"
  337. TracePrint "pageCount="&CStr(pageCount)
  338. // 点击数字键盘
  339. Tap 155, 1221
  340. Delay 500
  341. Dim number(3),i=3
  342. While pageCount > 0
  343. TracePrint "循环"
  344. number(i) = pageCount Mod 10
  345. TracePrint "number(i)="&CStr(number(i))
  346. pageCount = pageCount \ 10
  347. TracePrint "pageCount="&CStr(pageCount)
  348. i=i-1
  349. Wend
  350. For i = 0 To 3
  351. Call touchNumber(number(i))
  352. Delay 500
  353. Next
  354. End Function
  355.  
  356. Function inputSuffix()
  357. // 点击返回
  358. Tap 188, 1221
  359. Delay 500
  360. // 点击.号
  361. Tap 485, 1223
  362. Delay 500
  363. // 点击t
  364. Tap 323, 905
  365. Delay 500
  366. // 点击x
  367. Tap 216, 1115
  368. Delay 500
  369. // 点击t
  370. Tap 323, 905
  371. Delay 500
  372. // 点击enter
  373. Tap 665, 1226
  374. Delay 500
  375. KeyPress "Back"
  376. Delay 1000
  377. End Function
  378.  
  379. Log.Open
  380. Dim b=1, pageCount=1004
  381. While b = 1
  382.  
  383. Dim color
  384. Dim a=1
  385. Delay 1000
  386. // 点击导入联系人APP
  387. Tap 114, 139
  388. Delay 1000
  389. // 点击批量导入联系人
  390. Tap 87, 203
  391. Delay 1000
  392. // 删除原来的网址输入新网址
  393. Tap 697, 293
  394. Delay 1000
  395. For i = 1 To 8
  396. Tap 664, 1120
  397. Delay 500
  398. Next
  399. Call inputNumber(pageCount)
  400. Call inputSuffix()
  401.  
  402. pageCount = pageCount + 1
  403. Delay 3000
  404. // 点击开始导入
  405. Tap 73, 458
  406. Delay 500
  407.  
  408.  
  409. While a = 1
  410. color = CmpColor(662, 1239, "646464", 1.0)
  411. If color>-1 Then
  412. a = 1
  413. Else
  414. a=2
  415. End If
  416. Delay 1000
  417. Wend
  418.  
  419. Delay 1000
  420. KeyPress "Back"
  421. KeyPress "Back"
  422. Delay 1000
  423. KeyPress "Home"
  424. Delay 3000
  425.  
  426.  
  427. // 点击支付宝
  428. Tap 279, 146
  429. // 等待支付宝加载完成
  430. a=1
  431. While a = 1
  432. color = CmpColor(44, 706, "E98E10", 1.0)
  433. If color > -1 Then
  434. a = 2
  435. Else a=1
  436. End If
  437. Delay 1000
  438. Wend
  439. // 点击手机联系人
  440. Tap 358, 723
  441. Delay 2000
  442.  
  443. // 这个操作是为了让联系人加载好
  444. KeyPress "Home"
  445. Delay 2000
  446. // 点击支付宝
  447. Tap 279, 146
  448. Delay 3000
  449.  
  450. Call main()
  451.  
  452. Delay 1000
  453. KeyPress "Back"
  454. Delay 2000
  455. KeyPress "Home"
  456. Delay 3000
  457.  
  458. // 点击导入联系人APP
  459. Tap 105, 133
  460. Delay 1000
  461. // 点击批量删除联系人
  462. Tap 110, 297
  463. Delay 1000
  464. // 点击确定
  465. Tap 582, 774
  466. Delay 500
  467.  
  468. TracePrint "开始判断是否删除完成"
  469. a=1
  470. While a = 1
  471. TracePrint "进入循环"
  472. color = CmpColor(662, 1239, "646464", 1.0)
  473. If color > -1 Then
  474. TracePrint "color=646464"
  475. a = 1
  476. Else
  477. TracePrint "color!=646464"
  478. a=2
  479. End If
  480. Delay 1000
  481. Wend
  482.  
  483. Delay 1000
  484. KeyPress "Home"
  485. Delay 3000
  486.  
  487. Wend
  488. Log.Close
  489.  
  490.  
  491. //Log.Open
  492. // Call main()
  493. //Log.Close
Add Comment
Please, Sign In to add comment