Last active
May 18, 2018 03:52
-
-
Save liuqinh2s/d7104f943d58fcaa3fe5db83dbf09400 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function endFunction(path, number) | |
File.Write(path, number) | |
EndScript | |
End Function | |
// 转账按钮界面的所有操作都包装在这个函数里 | |
Function transfer(jpgStorePath, pngStorePath, path, number, itemNumber) | |
// 有没有头像的转账按钮位置不同,所以只能通过颜色来判断位置 | |
Dim transferPointX, transferPointY | |
// 转账按钮界面的下边界 | |
Dim borderX, borderY | |
// 转账按钮界面的性别颜色 | |
Dim blueX, blueY, redX, redY, greenX, greenY, gender | |
// 操作太过频繁的颜色 | |
Dim color7, color8 | |
// 账号存在异常的颜色 | |
Dim color4, color5 | |
// 操作上限颜色 | |
Dim color6 | |
// 今天操作太频繁了,请改天再来 | |
color6=CmpColor(13, 1263, "626262", 1.0) | |
If color6 > -1 Then | |
TracePrint "今天操作太频繁了,请改天再来" | |
SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-今日操作过多" & ".png" | |
Tap 545, 751 | |
Call endFunction(path, number) | |
End If | |
// 性别这里总共有三种颜色,绿色代表公司,粉红代表女,蓝色代表男 | |
// 蓝色 | |
FindColor 27, 585, 709, 1268, "FA9B25", 0, 1.0, blueX, blueY | |
If blueX > -1 And blueY > -1 Then | |
gender = "man" | |
End If | |
// 粉红色 | |
FindColor 27, 585, 709, 1268, "7E59F6", 0, 1.0, redX, redY | |
If redX > -1 And redY > -1 Then | |
gender = "woman" | |
End If | |
// 绿色 | |
FindColor 27, 585, 709, 1268, "A1B112", 0, 1.0, greenX, greenY | |
If greenX > -1 And greenY > -1 Then | |
gender = "company" | |
End If | |
// 截图 | |
FindColor 27, 585, 709, 1268, "FFFFFF", 3, 1.0, borderX, borderY | |
If borderX > -1 And borderY > -1 Then | |
SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-" & gender & ".png", 27, 585, 709, borderY | |
End If | |
// 点击:转账 | |
FindColor 15, 516, 40, 972, "E98E10", 0, 1.00, transferPointX, transferPointY | |
TracePrint "transferPointX="&transferPointX&", transferPointY="&transferPointY | |
If transferPointX > -1 And transferPointY > -1 Then | |
TracePrint "transferPointX="&transferPointX&", transferPointY="&transferPointY | |
Tap transferPointX, transferPointY | |
Delay 1000 | |
End If | |
TracePrint "点击转账结束" | |
// 点击转账后,如果出现:操作太过频繁,请稍后再试 | |
color7 = CmpColor(13, 1263, "626262", 1.0) | |
color8 = CmpColor(136, 574, "FFFFFF", 1.0) | |
If color7 > -1 And color8 > -1 Then | |
TracePrint "操作太频繁" | |
SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-操作太过频繁" & ".png" | |
Tap 548, 758 | |
Delay 1000 | |
// 开始返回一层 | |
Tap 45, 97 | |
Delay 1000 | |
Call endFunction(path, number) | |
End If | |
TracePrint "操作太过频繁验证通过" | |
// 点击转账后,如果账号存在异常 | |
color4 = CmpColor(13, 1263, "626262", 1.0) | |
color5 = CmpColor(168, 788, "FFFFFF", 1.0) | |
If color4 > -1 And color5>-1 Then | |
TracePrint "账号存在异常" | |
SnapShot pngStorePath & CStr(number) & "-" & CStr(itemNumber) & "-账号存在异常.png" | |
Tap 548, 759 | |
Delay 1000 | |
// 开始返回一层 | |
Tap 45, 97 | |
Delay 1000 | |
Else | |
TracePrint "进入克服网络延迟" | |
// 克服网络延迟,循环等待 | |
Dim b=0, returnColor | |
While b = 0 | |
returnColor = CmpColor(547, 508, "FFFFFF", 1.0) | |
If returnColor > -1 Then | |
b=1 | |
End If | |
Delay 1000 | |
Wend | |
// 有个提示:对方长时间没用支付宝,把这个提示叉掉 | |
Tap 682, 179 | |
Delay 1000 | |
TracePrint "叉掉点击验证" | |
// 去掉点击验证 | |
Dim verifyX, verifyY | |
FindColor 0, 236, 717, 258, "E98E10", 0, 1.0, verifyX, verifyY | |
If verifyX > -1 And verifyY > -1 Then | |
verifyX = verifyX - 2 | |
End If | |
TracePrint "准备截图" | |
SnapShot jpgStorePath & CStr(number) & "-" & CStr(itemNumber) & "-verify.jpg", 0, 224, verifyX, 273 | |
// 开始返回(两层) | |
Tap 35, 92 | |
Delay 1000 | |
Tap 35, 92 | |
Delay 1000 | |
TracePrint "返回两层" | |
End If | |
End Function | |
// 点击联系人电话 | |
Function clickPhone(jpgStorePath, pngStorePath, path, positionX, positionY, number) | |
TracePrint "进入clickPhone" | |
TracePrint "positionX=" & positionX & ", positionY=" & positionY | |
// 统计多少次之后出现:今日操作过多 | |
Dim count | |
// 如果有多条记录,就要进入选择界面 | |
Dim color1=CmpColor(13, 1263, "666666", 0.9) | |
If color1 > -1 Then | |
TracePrint "对应多个支付宝" | |
// 截取选择界面 | |
Dim leftTopX, leftTopY, rightBottomX, rightBottomY, itemColor, isSwipe, barColor | |
FindColor 0, 108, 694, 1259, "FFFFFF", 0, 1.00, leftTopX, leftTopY | |
FindColor 0, 108, 694, 1259, "FFFFFF", 2, 1.00, rightBottomX, rightBottomY | |
If leftTopX > -1 And leftTopY > -1 And rightBottomX > -1 And rightBottomY > -1 Then | |
SnapShot pngStorePath & CStr(number) & "-itemList.png", leftTopX, leftTopY, rightBottomX, rightBottomY | |
// 有些手机号对应9个支付宝,而界面只能容纳7个,如果多于6个item,itemColor这个位置就是纯白色 | |
itemColor = CmpColor(669, 1263, "FFFFFF", 1.0) | |
If itemColor > -1 Then | |
isSwipe = True | |
End If | |
// 选择记录,每个记录的单元格是恒定不变的,大概是x:620,y:151 | |
Dim itemNumber, itemHeight, clickX, clickY | |
itemNumber = (rightBottomY - leftTopY) / 151 | |
itemNumber = CInt(itemNumber) | |
itemHeight = (rightBottomY - leftTopY) / itemNumber | |
clickX = (rightBottomX - leftTopX) / 2 | |
TracePrint "itemNumber = " & itemNumber | |
For i = 0 To itemNumber - 1 Step 1 | |
TracePrint "i = " & i | |
// 如果不是第一次点,item界面是要重新点击才能获取的 | |
If Not (i = 0) Then | |
TracePrint "如果不是第一次点,item界面是要重新点击才能获取的" | |
Tap positionX, positionY | |
Delay 1000 | |
End If | |
// 点击item | |
clickY = leftTopY + i * itemHeight + itemHeight / 2 | |
Tap clickX, clickY | |
Delay 1000 | |
Call transfer(jpgStorePath, pngStorePath, path, number, i) | |
count = count + 1 | |
Next | |
If isSwipe = True Then | |
For i = 0 To 6 Step 1 | |
TracePrint "i = " & i+7 | |
TracePrint "如果不是第一次点,item界面是要重新点击才能获取的" | |
Tap positionX, positionY | |
Delay 1000 | |
Swipe 364, 1000, 364, 500 | |
Delay 1000 | |
// 点击item | |
clickY = leftTopY + i * itemHeight + itemHeight / 2 | |
Tap clickX, clickY | |
Delay 1000 | |
Call transfer(jpgStorePath, pngStorePath, path, number, i+7) | |
count = count + 1 | |
Next | |
End If | |
End If | |
Else | |
TracePrint "对应单个支付宝" | |
Call transfer(jpgStorePath, pngStorePath, path, number, 0) | |
count = count + 1 | |
End If | |
clickPhone=count | |
End Function | |
Function getNumber(path) | |
Dim str, number | |
str = File.Read(path) | |
If IsNull(str) Then | |
File.Write(path, 1) | |
End If | |
str = File.Read(path) | |
number = CInt(str) | |
TracePrint "number = " & number | |
getNumber=number | |
End Function | |
Function main() | |
// 等待Toast消失 | |
Delay 3000 | |
Dim pathRecordNumber="/sdcard/recordNumber.txt" | |
Dim pathCountLimit="/sdcard/countLimit.txt" | |
Dim jpgStorePath="/sdcard/dump/" | |
Dim pngStorePath="/sdcard/dump/withoutOCR/" | |
Dim isDirExist=Dir.Exist(jpgStorePath) | |
TracePrint "jpg isDirExist = " & isDirExist | |
If isDirExist=0 Then | |
TracePrint "jpg路径不存在,创建之" | |
Dir.Create (jpgStorePath) | |
Else | |
TracePrint "jpg存储路径已经存在" | |
End If | |
isDirExist = Dir.Exist(pngStorePath) | |
TracePrint "png isDirExist = " & isDirExist | |
If isDirExist=0 Then | |
TracePrint "png路径不存在,创建之" | |
Dir.Create (pngStorePath) | |
Else | |
TracePrint "png存储路径已经存在" | |
End If | |
Dim number=getNumber(pathRecordNumber) | |
// 统计点多少次之后出现:今日操作过多 | |
Dim totalCount=getNumber(pathCountLimit) | |
// 每个联系人条目的高度是128 | |
Dim positionX, positionY, height, phoneListItemLeftTopX, phoneListItemLeftTopY | |
height = 128 | |
Dim a=1 | |
While a=1 | |
// 根据滑动条检测是否滑动到底了 | |
// 如果滑动到底了,做完最后七个测试,然后退出大循环 | |
Dim color3 = CmpColor(710, 1273, "FFFFFF", 1.0) | |
If color3 > -1 Then | |
// do nothing | |
Else | |
a = 2 | |
TracePrint "滑动到底了" | |
End If | |
// 由于swipe需要一定的时间,而滑动条的显示时间又过短,所以swipe之后的delay只用了0.1秒,可能会发生swipe没完成就开始点击的情况,所以这里补足延迟时间,让swipe的惯性滑动充分完成 | |
Delay 2000 | |
// 找到可点击的位置 | |
FindColor 527, 224, 676, 600, "E98E10", 0, 1.0, positionX, positionY | |
If positionX > -1 And positionY > -1 Then | |
positionX = positionX - 100 | |
TracePrint "positionY = " & positionY | |
// 截取列表界面 | |
SnapShot pngStorePath & CStr(number) & "-phoneList.png" | |
// 每次点8个listItem | |
For i = 0 To 7 Step 1 | |
Touch positionX, positionY, 2000 | |
// 找到条目的左上角 | |
FindColor 0, 227, 11, 1277, "DDDDDD", 0, 1.0, phoneListItemLeftTopX, phoneListItemLeftTopY | |
If phoneListItemLeftTopX > -1 And phoneListItemLeftTopY > -1 Then | |
// 截取联系人电话 | |
SnapShot jpgStorePath & CStr(number) & "-phoneNumber.jpg", 140, phoneListItemLeftTopY, 351, phoneListItemLeftTopY+59 | |
Delay 1000 | |
totalCount = totalCount + clickPhone(jpgStorePath, pngStorePath, pathRecordNumber, positionX, positionY, number) | |
TracePrint "totalCount = " & totalCount | |
File.Write(pathCountLimit, totalCount) | |
TracePrint number | |
number = number + 1 | |
positionY = positionY + height | |
End If | |
Next | |
End If | |
Swipe 364, 732, 364, (732 - 400) | |
Delay 100 | |
Wend | |
File.Write(pathRecordNumber, number) | |
End Function | |
Function touchNumber(number) | |
If number = 1 Then | |
Tap 200, 914 | |
ElseIf number = 2 Then | |
Tap 359, 908 | |
ElseIf number = 3 Then | |
Tap 522, 909 | |
ElseIf number = 4 Then | |
Tap 199, 1014 | |
ElseIf number = 5 Then | |
Tap 361, 1015 | |
ElseIf number = 6 Then | |
Tap 520, 1013 | |
ElseIf number = 7 Then | |
Tap 199, 1121 | |
ElseIf number = 8 Then | |
Tap 361, 1122 | |
ElseIf number = 9 Then | |
Tap 519, 1122 | |
ElseIf number = 0 Then | |
Tap 361, 1222 | |
End If | |
End Function | |
Function inputNumber(pageCount) | |
TracePrint "开始输入数字" | |
TracePrint "pageCount="&CStr(pageCount) | |
// 点击数字键盘 | |
Tap 155, 1221 | |
Delay 500 | |
Dim number(3),i=3 | |
While pageCount > 0 | |
TracePrint "循环" | |
number(i) = pageCount Mod 10 | |
TracePrint "number(i)="&CStr(number(i)) | |
pageCount = pageCount \ 10 | |
TracePrint "pageCount="&CStr(pageCount) | |
i=i-1 | |
Wend | |
For i = 0 To 3 | |
Call touchNumber(number(i)) | |
Delay 500 | |
Next | |
End Function | |
Function inputSuffix() | |
// 点击返回 | |
Tap 188, 1221 | |
Delay 500 | |
// 点击.号 | |
Tap 485, 1223 | |
Delay 500 | |
// 点击t | |
Tap 323, 905 | |
Delay 500 | |
// 点击x | |
Tap 216, 1115 | |
Delay 500 | |
// 点击t | |
Tap 323, 905 | |
Delay 500 | |
// 点击enter | |
Tap 665, 1226 | |
Delay 500 | |
KeyPress "Back" | |
Delay 1000 | |
End Function | |
Log.Open | |
Dim b=1, pageCount=1004 | |
While b = 1 | |
Dim color | |
Dim a=1 | |
Delay 1000 | |
// 点击导入联系人APP | |
Tap 114, 139 | |
Delay 1000 | |
// 点击批量导入联系人 | |
Tap 87, 203 | |
Delay 1000 | |
// 删除原来的网址输入新网址 | |
Tap 697, 293 | |
Delay 1000 | |
For i = 1 To 8 | |
Tap 664, 1120 | |
Delay 500 | |
Next | |
Call inputNumber(pageCount) | |
Call inputSuffix() | |
pageCount = pageCount + 1 | |
Delay 3000 | |
// 点击开始导入 | |
Tap 73, 458 | |
Delay 500 | |
While a = 1 | |
color = CmpColor(662, 1239, "646464", 1.0) | |
If color>-1 Then | |
a = 1 | |
Else | |
a=2 | |
End If | |
Delay 1000 | |
Wend | |
Delay 1000 | |
KeyPress "Back" | |
KeyPress "Back" | |
Delay 1000 | |
KeyPress "Home" | |
Delay 3000 | |
// 点击支付宝 | |
Tap 279, 146 | |
// 等待支付宝加载完成 | |
a=1 | |
While a = 1 | |
color = CmpColor(44, 706, "E98E10", 1.0) | |
If color > -1 Then | |
a = 2 | |
Else a=1 | |
End If | |
Delay 1000 | |
Wend | |
// 点击手机联系人 | |
Tap 358, 723 | |
Delay 2000 | |
// 这个操作是为了让联系人加载好 | |
KeyPress "Home" | |
Delay 2000 | |
// 点击支付宝 | |
Tap 279, 146 | |
Delay 3000 | |
Call main() | |
Delay 1000 | |
KeyPress "Back" | |
Delay 2000 | |
KeyPress "Home" | |
Delay 3000 | |
// 点击导入联系人APP | |
Tap 105, 133 | |
Delay 1000 | |
// 点击批量删除联系人 | |
Tap 110, 297 | |
Delay 1000 | |
// 点击确定 | |
Tap 582, 774 | |
Delay 500 | |
TracePrint "开始判断是否删除完成" | |
a=1 | |
While a = 1 | |
TracePrint "进入循环" | |
color = CmpColor(662, 1239, "646464", 1.0) | |
If color > -1 Then | |
TracePrint "color=646464" | |
a = 1 | |
Else | |
TracePrint "color!=646464" | |
a=2 | |
End If | |
Delay 1000 | |
Wend | |
Delay 1000 | |
KeyPress "Home" | |
Delay 3000 | |
Wend | |
Log.Close | |
//Log.Open | |
// Call main() | |
//Log.Close | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment