/*
软件作者:https://xuhss.com/oxox/pro
*/
//本脚本仅供学习交流,切勿频繁使用,丧失游戏乐趣.
// 本脚本是快手小游戏的脚本,
// 包含游戏:消砖块,大圣来了
// 作者qq:203118908
// 更新日期:2018.6.22
// 使用本脚本需满足以下条件
// 1手机分辨率1920x1080
// 2安卓必安卓7以上(包括安卓7),免root使用
// 3需要下载群须文件中的快手小游戏截图解压至/sdcard
// 在桌面启动本脚本即可,会自动打开快手小游戏
//消砖块100连胜无压力(可以自己调节速度)
//大圣来了 玩10局胜7局
//本脚本仅供学习交流,切勿频繁使用,丧失游戏乐趣.
//除了消砖块界面外,其他界面都是用控件来识别界面的.
auto.waitFor();
setScreenMetrics(1080, 1920);
//请求截图
if(!requestScreenCapture()){
toast("请求截图失败");
exit();
}
let 消砖块按下时长=1
//如果手机反应迟钝,这个2可以适当增大
let 消砖块两个砖块间隔时长=50
// 砖块个数=2
//==================脚本主控制区======================================
// gameName = "连连看"
// gameName = "拯救萌宠"
// gameName = "圈圈消除"
//gameName = "消砖块"
gameName = "大圣来了"
let isMonkeyExist=false
packageName = "com.kwai.sogame";
imgPath="/sdcard/快手小游戏截图/";
files.ensureDir(imgPath);
// gamePlay(gameName)
// exit()
while(1){
let rndNumAd=r=Math.floor(Math.random()*(1000+1));
广告="快手小游戏Q群470614178,进群当最强王者"
是否发送广告=rndNumAd
errorTime=1
let page=whichPage();
log("\n当前界面=",page)
// exit()
// ---------------游戏测试的地方---------------------------------------
switch (page)
{
case "某游戏":
gamePlay(gameName)
// gameInterface()
break;
case "主页":
gameOpen(gameName)
break;
case "pk结果":
gameResult()
break;
case "聊天":
chatInterface()
break;
case "个人信息":
back()
sleep(2000)
break;
case "别人信息":
back()
sleep(2000)
break;
default:
if(currentPackage()==packageName){
sleep(300);
errorTime=errorTime+1
if(errorTime>100){
appOpen(packageName)
errorTime=1
}
break;
}else{
toastLog("当前包名不是快手小游戏\n当前包名是","="+currentPackage()+"=","包名长度=",currentPackage().length)
sleep(2000)
appOpen(packageName)
}
}
}
function gamePlay(gameName){
switch (gameName)
{
case "消砖块":
log("消砖块")
xiaoZhuanKuai()
break;
case "大圣来了":
log("大圣来了")
daShengLaiLe()
break;
default:
log(gameName,"游戏名字你写错了,没有这个游戏的脚本")
alert()
}
}
function gameResult(){
//在pk页,按两次back返回主页
//按一次是聊天
//按二次是主页
back()
sleep(2000)
for (let i = 0; i < 10; i++) {
if(whichPage()=="聊天"){
toastLog("从pk页返回到了聊天页")
back()
sleep(2000)
}else if(whichPage()=="主页"){
toastLog("从pk页返回到了聊天页又返回到了主页")
sleep(2000)
return true;
}else if(whichPage()=="某游戏"){
return;
}else{
sleep(1000);
}
}
toastLog("从pk页返回主页异常")
alert()
return false;
}
function chatInterface(){
//在聊天页,按一次back返回主页
back()
sleep(2000)
for (let i = 0; i < 10; i++) {
if(whichPage()=="聊天"){
toastLog("从聊天页返回到了主页失败,准备点击下一次back键")
back()
sleep(2000)
}else if(whichPage()=="主页"){
toastLog("从聊天页返回到了主页")
return true;
}else if(whichPage()=="某游戏"){
return;
}else{
sleep(1000)
}
}
toastLog("从聊天页返回主页异常")
alert()
return false;
}
function appOpen(packageName){
toast("启动快手小游戏")
sleep(2000)
if(currentPackage()==packageName){
}else{
launch(packageName);
sleep(1000);
}
for (let i = 0; i < 15; i++) {
if(whichPage()=="主页" ||whichPage()=="某游戏" ||whichPage()=="聊天" ||whichPage()=="pk结果"){
return true;
}else{
sleep(1000);
}
}
toastLog("快手小游戏启动异常")
alert()
return false;
}
function gameOpen(gameName){
log(gameName)
if(whichPage()=="主页"){
for(let i=0;i<10;i++){
if(text(gameName).exists()){
toastLog("在主页找到了游戏")
log(gameName,"开始点击它")
text(gameName).findOnce().parent().click()
sleep(2000)
return true;
}else{
上滑()
log("在主页的当前页面没找到游戏",gameName,"上滑页面");
}
}
log("在主页没找到游戏",gameName,"脚本停止运行");
alert()
exit()
}else{
toastLog("现在不在主页,不能打开任何游戏")
sleep(2000)
}
return false;
}
function alert(){
device.vibrate(2000);
sleep(1000);
device.vibrate(2000);
exit();
}
function whichPage(){
let w1=null,w2=null,w3=null,w4=null;
//某游戏
let featurePointCount=0
let interfaceFeaturePoint=[[403,44,"#FFEC00"],[507,31,"#FFEC00"],[679,57,"#FFEC00"]]
for(let i=0;i<interfaceFeaturePoint.length;i++){
let x=interfaceFeaturePoint[i][0]
let y=interfaceFeaturePoint[i][1]
let img=captureScreen()
let color=images.pixel(img, x, y)
let color1=colors.toString(color)
let color2=interfaceFeaturePoint[i][2]
// log("\n当前点",x,y,"的实际颜色=",color,"\n和其比较的颜色=",color2)
let result=colors.isSimilar(color1, color2)
if(result){
featurePointCount++;
}else{
break;
}
}
if(featurePointCount == interfaceFeaturePoint.length ){
return "某游戏"
}
w2 = text("换个游戏").findOnce();
w3 = id("msg_container").findOnce();
if(w1 != null && w2!=null && w3!=null){
return "pk结果"
}
//pk结果
w1 = text("换个对手").findOnce();
w2 = text("换个游戏").findOnce();
w3 = id("msg_container").findOnce();
if(w1 != null && w2!=null && w3!=null){
return "pk结果"
}
w1 = text("回到首页").findOnce();
w2 = text("对方已离开房间").findOnce();
w3 = id("msg_container").findOnce();
if(w1 != null && w2!=null && w3!=null){
return "pk结果"
}
//聊天
w1 = text("再来一局").findOnce();
w2 = text("发送").findOnce();
w3 = text("戳这里打字").findOnce();
w4 = text("换个对手").findOnce();
if(w1 != null && w2!=null && w3!=null && w4==null){
return "聊天"
}
//主页
w1 = text("找好友对战").findOnce();
w2 = text("最近对战").findOnce();
w3 = id("slide_tab").findOnce();
if(w1 != null && w2!=null && w3!=null){
return "主页"
}
//个人信息
w1 = textContains("快游号").findOnce();
w2 = text("常玩的游戏").findOnce();
w3 = id("carousel_view").find