手机按键精灵版的微信跳一跳脚本思路、源码
(2018-01-11 08:32:40)
标签:
微信跳一跳源码 |
注意:此脚本仅供交流图形识别等方法的实现
KeepCapture
Call 跳跃()
Call 随机延迟()
Delay 1000 + MyValue1 *
100 + ScorePlus
KeepCapture
Dim i,j
Dim rColor
i = 0
Do
rColor = GetPixelColor(0+i,0,0)
If rColor = "000000"
Then
midx =
i/2
Goto
获得手机分辨率标记1
Else
i = i +
1
End If
Loop
Rem 获得手机分辨率标记1
j = 0
Do
rColor = GetPixelColor(0,0+j,0)
If rColor = "000000"
Then
midy =
j/2
Goto
获得手机分辨率标记2
Else
j = j +
1
//TracePrint j
End If
Loop
Rem 获得手机分辨率标记2
TracePrint "手机分辨率为:
"&midx*2,midy*2
ReleaseCapture
Dim Count
Dim intx,inty
Call 找到棋子()
intx = Cheesex
inty = Cheesey
随机按压
(750,1500,1000)
Do
Call 找到棋子()
If Cheesex = 0 Then
Else
Count =
Count + 1
If Count
> 2 Then
Exit Do
End
If
End If
Loop
speed =
(sqr((Cheesex-intx)^2+(Cheesey-inty)^2))/1000
TracePrint "speed =
"&speed
Delay 3000
Call
重新开始游戏()
Randomize
MyValue1 = Int(((9-5+1)
* Rnd()) + 1)
//TracePrint
"MyValue1"&MyValue1
Randomize
MyValue2 = Int(((5-1+1)
* Rnd()) + 1)
//TracePrint
"MyValue2"&MyValue2
Dim MyValue
Randomize
MyValue =
Int(((20-(-20)+1) * Rnd()) + (-20))
Touch a+MyValue,
b+MyValue, t
//
Dim intX,intY
FindMultiColor
0,0,0,0,"3E3635","27|44|5F4540,-12|108|3D3535,9|197|663B39",0,1,intX,intY
If intX > -1 And intY
> -1 Then
Cheesex = intX + 8
Cheesey = intY + 190
Else
FindMultiColor
0,0,0,0,"3E3635","27|44|5F4540,-12|108|3D3535,9|197|663B39",0,0.95,intX,intY
If intX > -1 And intY > -1 Then
Cheesex =
intX + 8
Cheesey =
intY + 190
Else
FindMultiColor 0, 0, 0, 0, "3E3635",
"27|44|5F4540,-12|108|3D3535,9|197|663B39", 0, 0.9, intX,
intY
If intX
> -1 And intY > -1 Then
Cheesex = intX + 8
Cheesey = intY + 190
Else
Cheesex =
0
Cheesey = 0
End
If
End If
End if
TracePrint "Cheesex
,Cheesey =
"&Cheesex&","&Cheesey
//TracePrint "midxmidx =
"&midx
Dim rColor
rColor =
GetPixelColor(0, a, 0)
背景色 = rColor
//TracePrint "rColor =
"&rColor
Dim
是否相等
Dim 颜色数量
Dim 颜色数量1
dim i
颜色数量 =
GetColorNum(0,a,midx*2-1,a,rColor,1.0)
If 颜色数量 > 560
Then
//TracePrint "背景色1 = "&背景色
Else
i=1
Do
是否相等 =
CmpColor(i,a,背景色,1)
If 是否相等
> -1 Then
Else
rColor = GetPixelColor(i, a,
0)
颜色数量1 = GetColorNum(0, a,
midx * 2 - 1, a, rColor, 1.0)
If 颜色数量1 > 颜色数量
Then
颜色数量 = 颜色数量1
背景色 = rColor
Else
End If
End
If
i=i+1
If i =
midx*2-1 Then
Exit
Do
End
If
Loop
End If
//TracePrint "背景色 =
"&背景色
//因为背景色自上而下渐变,获取平均色点后,算出平均色点和上下两端的差值,作为背景色
//获取顶部背景色点
Dim
rColor1,rColor2
得到某一横线数量最多的颜色(1)
rColor1 = 背景色
//TracePrint
"这个点的颜色为:"&rColor1
Dim r1,g1,b1
ColorToRGB(rColor1,r1,g1,b1)
//TracePrint "上方取样色点为:
"&r1&","&g1&","&b1
//TracePrint "midx,midy
= "&midx&","&midy
得到某一横线数量最多的颜色(midy*2-1)
rColor2 = 背景色
//TracePrint
"这个点的颜色为:"&rColor2
Dim r2,g2,b2
ColorToRGB(rColor2,r2,g2,b2)
//TracePrint "下方取样色点为:
"&r2&","&g2&","&b2
Dim r,g,b
r = (r1 + r2) / 2
g = (g1 + g2) / 2
b = (b1 + b2) / 2
//转化为十六进制
Dim rr,gg,bb
rr = Hex(r)
gg = Hex(g)
bb = Hex(b)
BackgroundColor = bb
& gg & rr
//计算色差
Dim dc,dc1,dc2,dc3
dc1 = Hex(Abs(b1 -
b2))
dc2 = Hex(Abs(g1 -
g2))
dc3 = Hex(Abs(r1 -
r2))
//TracePrint
"差值dc=
"&dc1&","&dc2&","&dc3
//TracePrint
"Len(dc1)= "&Len(dc1)
//TracePrint
"Len(dc2)= "&Len(dc2)
//TracePrint
"Len(dc3)= "&Len(dc3)
If Len(dc1) = 1
Then
dc1 = "0" & dc1
End If
If Len(dc2) = 1
Then
dc2 = "0" & dc2
End If
If Len(dc3) = 1
Then
dc3 = "0" & dc3
//TracePrint "dc3 = "&dc3
End If
dc = dc1 & dc2 &
dc3
BackgroundColor =
BackgroundColor&"-"&dc
//TracePrint "a,b = "
&a&","&b//a和b是搜索范围的起点
//
Call 获取背景色()
TracePrint"背景色为:"&BackgroundColor
//TracePrint
"BackgroundColor = "&BackgroundColor
Dim i,j,k
//TracePrint
"a="&a
j=0
Do
i = 0
Do
Dim
是否相等1
是否相等1 =
CmpColor(a+i,b-600+j,BackgroundColor,1)
If 是否相等1
> -1 Then
//TracePrint
"匹配颜色的序号为:"&是否相等1
//TracePrint
RoughPointx-SearchScope+i
Else
//TracePrint "找到顶点"
Goto 搜索积木顶点标记1
End
If
i = i +
1
Loop until a+i>midx+a-2
j=j+1
Loop Until b - 500 + j
> b
//TracePrint
"找不到想要的顶点,循环自动结束后退出到这里"
Rem 搜索积木顶点标记1
k = 0
Do
Dim 是否相等2
是否相等2 =
CmpColor(a+i+k,b-600+j,BackgroundColor,1)
If 是否相等2 > -1 Then
Exit
Do
Else
End If
k = k + 1
//TracePrint "k = "&k
Loop
//TracePrint "k =
"&k
Dim rColor
rColor =
GetPixelColor(a+i+k/2, b-600+j,0)
//TracePrint
"新积木顶点的颜色为:"&rColor
Dim IntX,IntY
FindColor
a+i+k/2-100,b-600+j,a+i+k/2+100,b-600+j+200,"5D69F3|F89C6B|2789F4|B36C0D|7776EF|6BAB50|433F3D|262626",0,1.0,intX,intY
If intX >-1
then
Traceprint "找到加分积木"
Call 随机延迟()
ScorePlus = MyValue1*1000+1000
Else
ScorePlus = 0
End If
//TracePrint "i =
"&i
Delay 100
ArruratePointx = a + i +
k / 2
topy = b-600+j
//TracePrint
"得到了新积木顶点横坐标X = "&ArruratePointx
Dim i=1
//TracePrint "topy =
"&topy
Do
Dim 是否相等1
是否相等1 =
CmpColor(ArruratePointx,a+i,BackgroundColor,1)
If 是否相等1 > -1 Then
Exit
Do
Else
End If
i=i+1
Loop
//TracePrint "纵向扫描长度为
"&i
ArruratePointy = a +
(i-143) / 2//这里需要减去积木的高度143像素,这是1080P手机下的值,唯一不能适配只能填入的值
whitepointx = -1
Dim IntX,IntY
FindMultiColor
10,midy-400,midx*2-10,midy,"F5F5F5","-19|-6|F5F5F5,18|-1|F5F5F5",0,1,intX,intY
If intX > -1
Then
whitepointx = intX
whitepointy = intY
Else
FindMultiColor
10,midy-400,midx*2-10,midy,"F5F5F5","-19|-5|F5F5F5,19|-3|F5F5F5",0,1,intX,intY
If intX > -1 Then
whitepointx = intX
whitepointy = intY
Else
FindMultiColor
10,midy-400,midx*2-10,midy,"F5F5F5","-17|-9|F5F5F5,18|-3|F5F5F5",0,1,intX,intY
If intX
> -1 Then
whitepointx = intX
whitepointy = intY
Else
End
If
End If
//TracePrint "找不到白点"
End If
//计算中心点
Dim dd=0
Dim
Distance,Distance1,Distance2
Dim i,j,k,l
Dim t
Dim
SearchScopex,SearchScopey
SearchScopex = 250
SearchScopey = 250
Call 找到棋子()
//如果找到白点则直接用白点
If Cheesex = 0
Then
Call 重新开始游戏()
End If
Call 寻找白点()
If whitepointx > 0
Then
ContinuousjumpCount = ContinuousjumpCount +
1
Call 随机连击()
If ContinuousjumpCount > MyValue2
Then
dd=20
End If
//TracePrint "用白点"
Distance = Sqr((Cheesex - whitepointx) ^ 2 +
(Cheesey - whitepointy) ^ 2)
Dim IntX,IntY
FindColor
whitepointx-100,whitepointy-100,whitepointx+100,whitepointy+100,"5D69F3|F89C6B|2789F4|B36C0D|7776EF|6BAB50|433F3D|262626",0,1.0,intX,intY
If intX >-1 then
Traceprint
"找到加分积木"
Call
随机延迟()
ScorePlus
= MyValue1*1000+1000
Else
ScorePlus
= 0
End If
Goto 跳跃标记1
Else
ContinuousjumpCount = 0
dd = 0
End If
If Cheesex
//TracePrint"积木在右边"
搜索积木顶点(midx, Cheesey)
Else
//TracePrint"积木在左边"
搜索积木顶点 10, Cheesey
End
If
//方法一:根据角度计算距离的方法稳定性好,但是精确度会逐渐下降
Distance1 =
(Sqr((Cheesex - ArruratePointx) ^ 2)) / cos((pai/180)*30)
//TracePrint
"计算得到距离为:"&Distance1
//方法二:扫描确定Y坐标,精确度高但是稳定性差,在和Distance1差距不大的情况下选择Distance2,否则选择Distance1
计算新积木纵坐标(topy)
Distance2 = Sqr((Cheesex
- ArruratePointx) ^ 2 + (Cheesey - ArruratePointy) ^ 2)
//TracePrint
"abs(Distance1 - Distance2) = "&abs(Distance1
- Distance2)
If abs(Distance1 -
Distance2) < 30 Then
Distance = Distance2
//TracePrint "选用方法一"
Else
Distance = Distance1
//TracePrint "选用方法二"
End If
Rem 跳跃标记1
t=
(Distance+dd)/speed
随机按压(750,1500,t)
Dim IntX,IntY
FindColor
0,0,midx*2,midy*2,"77C700",0,1.0,intX,intY
If intX >-1
then
随机按压(intX,intY,100)
Else
End If
Delay 2000
一、采用三种计算距离方式:1、扫描新积木顶点算出横坐标,棋子和新积木中点的连线和水平方向夹角其实是固定角度,大约30度,利用这一点可以直接算出距离,该方法比较稳定,但是时间长容易偏离。2、直接扫描新积木顶点和下边界,这样可以算出新积木的中点,但是结果不稳定,不过算对了就比较精确。3、找白点直接算,前提是上一次跳到积木中点
二、由于很多脚本的刷的高分上不了榜单,怀疑一方面微信加入了行为检测,一方面是高分控制,解决方法是模拟人的行为,将所有固定数据改为允许范围内的随机数据,如按压点在给定范围内随机,每次跳跃停顿时间随机,加分积木一定要停留并拿到这个分数,主动打断连击,每次都能连击必然上不了榜单
三、打算适配所有手机,所以会故意跳出积木以计算跳跃速度
四、本脚本仅供交流学习,不做商业用途,源码首发公众号“小浅玩机”,欢迎来观光:)
////////////////////////////复制以下内容/////////////////////////////////
Dim pai = 3.14159265358979323846
Dim BackgroundColor
Dim ArruratePointx,ArruratePointy,topy
Dim whitepointx,whitepointy
Dim Cheesex,Cheesey
Dim speed
Dim midx,midy//中点坐标
Dim ContinuousjumpCount = 0//连跳中心点计次
Dim ScorePlus = 0//加分的积木停留时间
Dim MyValue1,MyValue2
Dim 背景色
ShowMessage "5秒后开始"
Delay 5000
Call 获得手机分辨率()
Call 计算速度()
///////////////////////////循环部分///////////////////////////
Do
Loop
/////////////////////////////////////////////////////////////
///////////////////////////准备工作///////////////////////////
Sub 获得手机分辨率
End Sub
Sub 计算速度
End Sub
Sub 随机延迟
End Sub
Sub 随机连击
End Sub
Function 随机按压(a,b,t)
End Function
/////////////////////////////////////////////////////////////
///////////////////////////距离计算///////////////////////////
Sub 找到棋子
End Sub
Function 得到某一横线数量最多的颜色(a)//a是代表纵坐标y的值
End Function
Sub 获取背景色()
End Sub
Function 搜索积木顶点(a, b)
End Function
Function 计算新积木纵坐标(a)
End Function
Sub 寻找白点
End Sub
/////////////////////////////////////////////////////////////
////////////////////////跳跃及重新开始////////////////////////
Sub 跳跃
End Sub
Sub 重新开始游戏
End Sub
////////////////////////////复制以上内容/////////////////////////////////