1.参考知乎教你用Python来玩微信跳一跳,鉴于本人Python一直都是半吊子水平,之前打算用python刷分,可无奈安装python环境各种模块缺失,报错不停,于是乎,使用Java重新实现了一下。

2.环境配置及相关说明:

1>Windows系统,本人win10

2>JAVA环境安装,JDK7以上即可

3>安卓手机一部、数据线一条

4>电脑安装ADB驱动,连接安卓手机,同时打开USB调试模式

5>打开微信小程序的跳一跳游戏,JAVA程序跑起来,具体代码往下看

6>本人所用为魅蓝note2安卓手机,屏幕 分辨率1920x1080,不同型号的手机,可能需要调整相关参数,具体看代码注释

7>增加了刷分失败后游戏自动重新开局功能

8>娱乐而已,不要较真,据说微信官方已经关注,分数太高可能会被清零,哈哈

3.废话不多说,上代码:

package com.yihusitian.gamehelper;import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;import javax.imageio.ImageIO;/*** 参考知乎  * *  @link https://zhuanlan.zhihu.com/p/32452473* * 跳一跳辅助* * @author LeeHo*/
public class JumpJumpHelper
{private static final String IMAGE_NAME              = "current.png";private static final String STORE_DIR               = "d:/jump_screencapture";//数量private static final int    imageLengthLength       = 5;//存放图片的大小private static final long[] imageLength             = new long[imageLengthLength];private final RGBInfo       rgbInfo                 = new RGBInfo();private final String[]      ADB_SCREEN_CAPTURE_CMDS ={ "adb shell screencap -p /sdcard/" + IMAGE_NAME,"adb pull /sdcard/current.png " + STORE_DIR };//截屏中游戏分数显示区域最下方的Y坐标,300是 1920x1080的值,根据实际情况修改private final int           gameScoreBottomY        = 300;//按压的时间系数,可根据具体情况适当调节private final double        pressTimeCoefficient    = 1.35;//按压的起始点坐标,也是再来一局的起始点坐标private final int           swipeX                  = 550;private final int           swipeY                  = 1580;//二分之一的棋子底座高度private final int           halfBaseBoardHeight     = 20;//棋子的宽度,从截屏中量取,自行调节private final int           halmaBodyWidth          = 74;//游戏截屏里的两个跳板的中点坐标,主要用来计算角度,可依据实际的截屏计算,计算XY的比例private final int           boardX1                 = 813;private final int           boardY1                 = 1122;private final int           boardX2                 = 310;private final int           boardY2                 = 813;/*** 获取跳棋以及下一块跳板的中心坐标** @return* @author LeeHo* @throws IOException* @update 2017年12月31日 下午12:18:22*/private int[] getHalmaAndBoardXYValue(File currentImage) throws IOException{BufferedImage bufferedImage = ImageIO.read(currentImage);int width = bufferedImage.getWidth();int height = bufferedImage.getHeight();System.out.println("宽度:" + width + ",高度:" + height);int halmaXSum = 0;int halmaXCount = 0;int halmaYMax = 0;int boardX = 0;int boardY = 0;//从截屏从上往下逐行遍历像素点,以棋子颜色作为位置识别的依据,最终取出棋子颜色最低行所有像素点的平均值,即计算出棋子所在的坐标for (int y = gameScoreBottomY; y < height; y++){for (int x = 0; x < width; x++){processRGBInfo(bufferedImage, x, y);int rValue = this.rgbInfo.getRValue();int gValue = this.rgbInfo.getGValue();int bValue = this.rgbInfo.getBValue();//根据RGB的颜色来识别棋子的位置,if (rValue > 50 && rValue < 60 && gValue > 53 && gValue < 63 && bValue > 95 && bValue < 110){halmaXSum += x;halmaXCount++;//棋子底行的Y坐标值halmaYMax = y > halmaYMax ? y : halmaYMax;}}}if (halmaXSum != 0 && halmaXCount != 0){//棋子底行的X坐标值int halmaX = halmaXSum / halmaXCount;//上移棋子底盘高度的一半int halmaY = halmaYMax - halfBaseBoardHeight;//从gameScoreBottomY开始for (int y = gameScoreBottomY; y < height; y++){processRGBInfo(bufferedImage, 0, y);int lastPixelR = this.rgbInfo.getRValue();int lastPixelG = this.rgbInfo.getGValue();int lastPixelB = this.rgbInfo.getBValue();//只要计算出来的boardX的值大于0,就表示下个跳板的中心坐标X值取到了。if (boardX > 0){break;}int boardXSum = 0;int boardXCount = 0;for (int x = 0; x < width; x++){processRGBInfo(bufferedImage, x, y);int pixelR = this.rgbInfo.getRValue();int pixelG = this.rgbInfo.getGValue();int pixelB = this.rgbInfo.getBValue();//处理棋子头部比下一个跳板还高的情况if (Math.abs(x - halmaX) < halmaBodyWidth){continue;}//从上往下逐行扫描至下一个跳板的顶点位置,下个跳板可能为圆形,也可能为方框,取多个点,求平均值if ((Math.abs(pixelR - lastPixelR) + Math.abs(pixelG - lastPixelG) + Math.abs(pixelB - lastPixelB)) > 10){boardXSum += x;boardXCount++;}}if (boardXSum > 0){boardX = boardXSum / boardXCount;}}//按实际的角度来算,找到接近下一个 board 中心的坐标boardY = (int) (halmaY - Math.abs(boardX - halmaX) * Math.abs(boardY1 - boardY2)/ Math.abs(boardX1 - boardX2));if (boardX > 0 && boardY > 0){int[] result = new int[4];//棋子的X坐标result[0] = halmaX;//棋子的Y坐标result[1] = halmaY;//下一块跳板的X坐标result[2] = boardX;//下一块跳板的Y坐标result[3] = boardY;return result;}}return null;}/*** 执行命令** @param command* @author LeeHo* @update 2017年12月31日 下午12:13:39*/private void executeCommand(String command){Process process = null;try{process = Runtime.getRuntime().exec(command);System.out.println("exec command start: " + command);process.waitFor();BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getErrorStream()));String line = bufferedReader.readLine();if (line != null){System.out.println(line);}System.out.println("exec command end: " + command);}catch (Exception e){e.printStackTrace();}finally{if (process != null){process.destroy();}}}/*** ADB获取安卓截屏* * @author LeeHo* @update 2017年12月31日 下午12:11:42*/private void executeADBCaptureCommands(){for (String command : ADB_SCREEN_CAPTURE_CMDS){executeCommand(command);}}/*** 跳一下** @param distance* @author LeeHo* @update 2017年12月31日 下午12:23:19*/private void doJump(double distance){System.out.println("distance: " + distance);//计算按压时间,最小200毫秒int pressTime = (int) Math.max(distance * pressTimeCoefficient, 200);System.out.println("pressTime: " + pressTime);//执行按压操作String command = String.format("adb shell input swipe %s %s %s %s %s", swipeX, swipeY, swipeX, swipeY,pressTime);System.out.println(command);executeCommand(command);}/*** 再来一局* * @author LeeHo* @update 2017年12月31日 下午12:47:06*/private void replayGame(){String command = String.format("adb shell input tap %s %s", swipeX, swipeY);executeCommand(command);}/*** 计算跳跃的距离,也即两个点之间的距离** @param halmaX* @param halmaY* @param boardX* @param boardY* @return* @author LeeHo* @update 2017年12月31日 下午12:27:30*/private double computeJumpDistance(int halmaX, int halmaY, int boardX, int boardY){return Math.sqrt(Math.pow(Math.abs(boardX - halmaX), 2) + Math.pow(Math.abs(boardY - halmaY), 2));}public static void main(String[] args){try{File storeDir = new File(STORE_DIR);if (!storeDir.exists()) {boolean flag = storeDir.mkdir();if (!flag) {System.err.println("创建图片存储目录失败");return;}}JumpJumpHelper jumpjumpHelper = new JumpJumpHelper();//执行次数int executeCount = 0;for (;;){//执行ADB命令,获取安卓截屏jumpjumpHelper.executeADBCaptureCommands();File currentImage = new File(STORE_DIR, IMAGE_NAME);if (!currentImage.exists()){System.out.println("图片不存在");continue;}long length = currentImage.length();imageLength[executeCount % imageLengthLength] = length;//查看是否需要重新开局jumpjumpHelper.checkDoReplay();executeCount++;System.out.println("当前第" + executeCount + "次执行!");//获取跳棋和底板的中心坐标int[] result = jumpjumpHelper.getHalmaAndBoardXYValue(currentImage);if (result == null){System.out.println("The result of method getHalmaAndBoardXYValue is null!");continue;}int halmaX = result[0];int halmaY = result[1];int boardX = result[2];int boardY = result[3];System.out.println("halmaX: " + halmaX + ", halmaY: " + halmaY + ", boardX: " + boardX + ", boardY: "+ boardY);//计算跳跃的距离double jumpDistance = jumpjumpHelper.computeJumpDistance(halmaX, halmaY, boardX, boardY);jumpjumpHelper.doJump(jumpDistance);//每次停留2.5秒TimeUnit.MILLISECONDS.sleep(2500);}}catch (Exception e){e.printStackTrace();}}/*** 检查是否需要重新开局* * @author LeeHo* @update 2017年12月31日 下午1:39:18*/private void checkDoReplay(){if (imageLength[0] > 0 && imageLength[0] == imageLength[1] && imageLength[1] == imageLength[2]&& imageLength[2] == imageLength[3] && imageLength[3] == imageLength[4]){//此时表示已经连续5次图片大小一样了,可知当前屏幕处于再来一局Arrays.fill(imageLength, 0);//模拟点击再来一局按钮重新开局replayGame();}}/*** 获取指定坐标的RGB值** @param bufferedImage* @param x* @param y* @author LeeHo* @update 2017年12月31日 下午12:12:43*/private void processRGBInfo(BufferedImage bufferedImage, int x, int y){this.rgbInfo.reset();int pixel = bufferedImage.getRGB(x, y);//转换为RGB数字  this.rgbInfo.setRValue((pixel & 0xff0000) >> 16);this.rgbInfo.setGValue((pixel & 0xff00) >> 8);this.rgbInfo.setBValue((pixel & 0xff));}class RGBInfo{private int RValue;private int GValue;private int BValue;public int getRValue(){return RValue;}public void setRValue(int rValue){RValue = rValue;}public int getGValue(){return GValue;}public void setGValue(int gValue){GValue = gValue;}public int getBValue(){return BValue;}public void setBValue(int bValue){BValue = bValue;}public void reset(){this.RValue = 0;this.GValue = 0;this.BValue = 0;}}
}

JAVA实现微信跳一跳辅助相关推荐

  1. JAVA实现微信跳一跳辅助(手动)

    工具:total control . eclipse/java环境 . ADB 环境:1.1 total control 官网下载地址: http://tc.sigma-rt.com.cn/   下载 ...

  2. 微信跳一跳java实现自动跳_微信跳一跳辅助Java代码实现

    微信跳一跳辅助的Java具体实现代码,供大家参考,具体内容如下 1.参考知乎教你用Python来玩微信跳一跳,鉴于本人Python一直都是半吊子水平,之前打算用python刷分,可无奈安装python ...

  3. 100行微信跳一跳java_安卓版微信跳一跳辅助 跳一跳辅助Java代码

    安卓版微信跳一跳辅助,java实现,具体内容如下 已经看到网上有大神用各种方式实现了,我这是属于简易版ADB命令式实现. 操作方法 1.光标移动到起始点,点击FORM 2.光标移动到目标点,点击TO ...

  4. python跳一跳编程构造_python实现微信跳一跳辅助工具步骤详解

    说明 1.windows上安装安卓模拟器,安卓版本5.1以上 2.模拟器里下载安装最新的微信6.6.1 3.最好使用python2.7,python3的pyhook包有bug,解决比较麻烦 步骤 1. ...

  5. python微信公众号秒杀代码_微信跳一跳辅助python代码实现

    微信跳一跳辅助python代码实现 来源:中文源码网    浏览: 次    日期:2018年9月2日 [下载文档:  微信跳一跳辅助python代码实现.txt ] (友情提示:右键点上行txt文档 ...

  6. python hook pc微信_python实现微信跳一跳辅助工具步骤详解

    说明 1.windows上安装安卓模拟器,安卓版本5.1以上 2.模拟器里下载安装最新的微信6.6.1 3.最好使用python2.7,python3的pyhook包有bug,解决比较麻烦 步骤 1. ...

  7. python实现微信hook_python实现微信跳一跳辅助工具步骤详解

    说明 1.windows上安装安卓模拟器,安卓版本5.1以上 2.模拟器里下载安装最新的微信6.6.1 3.最好使用python2.7,python3的pyhook包有bug,解决比较麻烦 步骤 1. ...

  8. 微信跳一跳辅助php,微信跳一跳辅助python代码实现

    微信跳一跳辅助的python具体实现代码,供大家参考,具体内容如下 这是一个 2.5D 插画风格的益智游戏,玩家可以通过按压屏幕时间的长短来控制这个「小人」跳跃的距离.可能刚开始上手的时候,因为时间距 ...

  9. c语言跳一跳辅助源码,.NET 开发一个微信跳一跳辅助程序(附源码)

    原标题:.NET 开发一个微信跳一跳辅助程序(附源码) 来源:中国.NET研究协会 cnblogs.com/dotnet-org-cn/p/8149693.html 前言 微信更新了,出现了一个小游戏 ...

最新文章

  1. 门户网站建设与运营需要付出更多成本
  2. HSmartWindowControl 之 摄像头实时显示( 使用 WPF )
  3. Android异常与性能优化相关面试问题-内存管理面试问题详解
  4. jQuery 重置/reset()表单
  5. frameworks/av/media/CedarX-Projects/CedarAndroidLib/LIB_KK44_/Android.mk: No such file or directory
  6. linux限制单个用户使用,linux下限制用户使用系统资源
  7. 男子趁前女友熟睡翻开眼皮,刷脸转走15万!支付宝:几率很小
  8. 连接查询(交叉连接,内连接,外连接,自然连接)
  9. 网络空间信息安全-密码学-信息密码技术基础
  10. 《大数据之路:阿里巴巴大数据实践》-第1篇 数据技术篇 -第5章 实时技术
  11. Power bi 3.10 折线和堆积柱形图
  12. iso 开发学习--简易音乐播放器(基于iPhone4s屏幕尺寸)
  13. python peewee 批量插入
  14. 微信公众号支付完整流程
  15. python对文件进行tar和gz格式的压缩和解压缩(亲测,可用)
  16. JAVA名片注册_JavaWeb练习-网上名片管理系统
  17. 算法训练 奥运会开幕式 Java
  18. WindowsServer2012R2搭建Web服务器(腾讯云)
  19. uni-app 中模拟器真机运行app
  20. 《大众创业做电商——淘宝与微店 开店 运营 推广 一册通》导读

热门文章

  1. MySQL存储引擎(InnoDB引擎)
  2. QRCode二维码生成方案及其在带LOGO型二维码中的应用
  3. Lubuntu精简记录
  4. 30台无盘服务器配置,带30台机器的无盘服务器配置方案两套
  5. 老兵不死,只是凋零:前九枝兰架构师王晓辉
  6. 苹果自研M1芯片的功耗和发热都仅为Intel x86芯片的1/3左右
  7. 一文了解websocket和socket(论点:概念、流程、区别)
  8. java课程设计-多人聊天工具(socket+多线程)
  9. 蓝桥杯单片机学习日记3-矩阵键盘的使用,线反转法,三步消抖,按键长按与短按
  10. 【转载】30岁开始实现我的程序员梦