WeChat Jump가 지원하는 특정 Java 구현 코드는 참조 용입니다. 특정 내용은 다음과 같습니다
1. Zhihu를 참조하여 Python을 사용하여 WeChat을 재생하는 방법을 가르쳐주십시오. 내가 항상 반 구운 파이썬 이었기 때문에, 나는 이전에 Python을 사용하여 점수를 기록 할 계획 이었지만, Python 환경을 설치하는 것 외에는 선택의 여지가 없었으며 다양한 모듈에 누락되어 오류가보고되었습니다. 그래서 나는 Java를 사용하여 그것을 다시 구현했습니다.
2. 환경 구성 및 관련 지침 :
1) Windows 시스템, 나는 Win10입니다
2) ava 환경, JDK7 이상을 설치하십시오
3) 하나의 안드로이드 폰, 하나의 데이터 케이블
4) 컴퓨터의 ADB 드라이버를 설치하고 Android 전화에 연결 한 다음 USB 디버깅 모드를 동시에 켜십시오.
5) Wechat Mini 프로그램의 점프 게임을 열고 Java 프로그램이 실행되고 아래의 특정 코드를 읽으십시오.
6) 1920x1080의 화면 해상도와 함께 Meilan Note2 Android 전화를 사용합니다. 휴대 전화의 다른 모델은 관련 매개 변수를 조정해야 할 수도 있습니다. 자세한 내용은 코드 주석을 참조하십시오.
7) 점수를 얻지 못한 후 게임을 자동으로 다시 시작하는 기능이 추가되었습니다.
8) 그것은 단지 엔터테인먼트 일뿐입니다. 진지하지 마십시오. WeChat 관계자는 이에주의를 기울 였다고합니다. 점수가 너무 높으면 지울 수 있습니다. 하하
3. 더 이상 고민하지 않으면 코드를 추가하십시오.
패키지 com.yihusitian.gamehelper; java.awt.image.bufferedimage import; import java.io.bufferedReader; import java.io.file; import java.io.ioexception; import java.io.inputStreamReader; import java.util.arrays; java.util.concurrent.timeUnit import; import javax.imageio.imageio; /** * 참조 ZHIHU * * @link <a href = "https://zhuanlan.zhihu.com/p/32452473"rel = "external nofollow"rel = "external nofollow"target = "_blank"> https://zhuanlan.zhihu.com/p/32442473 * @Author Leeho */ Public Class JumpJumphelper {private static final String image_name = "current.png"; 개인 정적 최종 문자열 store_dir = "d :/jump_screencapture"; // 수량 비공개 정적 최종 최종 intimelengrength = 5; // 이미지 스토리지 크기 스토리지 개인 정적 최종 Long [] imageLength = New Long [imageLengthlength]; 개인 최종 RGBINFO RGBINFO = NEW RGBINFO (); 개인 최종 문자열 [] ADB_SCREEN_CAPTURE_CMDS = { "ADB SHELL SCREENCAP -P /SDCARD /" + IMADE_NAME, "ADB PULL /SDCARD/CURRENT.PNG" + Store_DIR}; // 스크린 샷의 게임 점수 표시 영역의 하단에있는 Y 좌표, 300은 1920x1080입니다. 실제 상황에 따라 개인 최종 INT GamesCoreBottomy = 300을 수정하십시오. // 프레스 타임 계수는 특정 상황에 따라 적절하게 조정할 수 있습니다. 개인 최종 Double PresstimeCoefficial = 1.35; // 프레스의 시작점 좌표는 다음 게임의 시작점 좌표이기도합니다. 개인 최종 int swipex = 550; 개인 최종 INT Swipey = 1580; // 체스 조각의 기본 높이는 개인 최종 최종 int HalfBaseboardHeight = 20입니다. // 체스 조각의 너비는 스크린 샷에서 가져와 개인 최종 int를 직접 조정합니다. HalmabodyWidth = 74; // 게임 스크린 샷에서 두 스프링 보드의 중간 점 좌표는 주로 각도를 계산하는 데 사용됩니다. XY의 비율은 실제 스크린 샷에 따라 계산할 수 있습니다. 개인 최종 int Boardx1 = 813; 개인 최종 int Boardy1 = 1122; 개인 최종 int Boardx2 = 310; 개인 최종 int Boardy2 = 813; / ** * 내년 스프링 보드의 체커와 중앙 좌표를 얻습니다 * @return * @Author Leeho * @Throws IOException * @Update 2017 년 12 월 31 일 오후 12 월 31 일 오후 10시 */ private int [] gethalmaandboardxyValue (파일 전류)는 ioexection {bufferedimage vbilleceation {indimeio.rede); int width = bufferedImage.getWidth (); int height = bufferedImage.getheight (); System.out.println ( "너비 :" + 너비 + ", 높이 :" + 높이); int halmaxsum = 0; int halmaxcount = 0; int halmaymax = 0; int boardx = 0; int boardy = 0; // 스크린 샷에서 픽셀 포인트를 위에서 아래로 전송하고 위치 인식의 기초로 체스 조각의 색상을 사용하십시오. 마지막으로, 체스 조각 색상의 가장 낮은 줄에있는 모든 픽셀의 평균값, 즉 (int y = gamescorebottomy; y <높이; 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) {// 체스 조각의 하단 행의 좌표 값 halmax = halmaxsum /halmaxcount; // 체스 조각의 절반을 섀시 높이로 이동 int halmay = halmaymax -HalfbaseboardHeight; // 게임에서 시작하여 (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 (); // 체스 조각의 헤드가 다음 스프링 보드보다 높은 경우 (math.abs (x -halmax) <halmabodywidth) {계속; } // 다음 스프링 보드의 위에서 아래로 스캔합니다. 다음 스프링 보드는 원이나 상자 일 수 있습니다. 여러 포인트를 가져 와서 평균 if ((Math.abs (Pixelr -LastPixelr) + math.abs (pixelg -lastpixelg) + math.abs (pixelb -lastpixelb))> 10) {boardxsum + = x; BoardxCount ++; }} if (boardxsum> 0) {boardx = boardxsum / boardxcount; }} // 실제 각도에서 다음 보드 중앙에 가까운 좌표를 찾으십시오. 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 좌표 결과 [0] = halmax; // y 좌표 결과 [1] = Halmay; // x 좌표 결과 [2] = boardx; // y 좌표 결과 [3] = Boardy; 반환 결과; }} return null; } / ** * 명령 실행 * * @param command * @author leeho * @update 2017 년 12 월 31 일 오후 12:13:39 * / private void executeCommand (String Command) {process process = null; {process = runtime.getRuntime (). exec (명령); System.out.println ( "Exec 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 (예외 e) {e.printstacktrace (); } 마지막으로 {if (process! = null) {process.destroy (); }}} / ** * adb가 안드로이드 스크린 샷을 가져옵니다 * * @author leeho * @update 2017 년 12 월 31 일 오후 12시 11:42 * / private void executeadbcapturecommands () {for (string 명령 : adb_screen_capture_cmds) {executeCommand (명령); }} / ** * jump * * @param 거리 * @author leeho * @update 2017 년 12 월 31 일 오후 12:23:19 pm * / private void dojump (double distone) {System.out.println ( "거리 :" + 거리); // 프레스 타임을 계산, 최소 200ms int presstime = (int) math.max (거리 * presstimeCoefficial, 200); System.out.println ( "프레스 타임 :" + 프레스 타임); // 프레스 작동 문자열 명령 = String.format ( "ADB 쉘 입력 스 와이프 %s %s %s %s %s", swipex, swipey, swipex, swipey, presstime); System.out.println (명령); 집행 명령 (명령); } / ** * 또 다른 게임 * * @author leeho * @update 2017 년 12 월 31 일 오후 12시 47 분 66 분 * / 개인 void ReplayGame () {String Command = String.Format ( "adb 쉘 입력 탭 %s %s", swipex, swipey); 집행 명령 (명령); } / ** * 점프의 거리, 즉 두 지점 사이의 거리를 계산합니다. 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 ( "이미지 스토리지 디렉토리 만들기 실패"); 반품; }} JumpJumpHelper JumpJumpHelper = New JumpJumpHelper (); // 실행 수 int executeCount = 0; for (;;) {// adb 명령을 실행하여 Android Screenshot jumpjumphelper.executeadbcapturecommands ()를 얻습니다. 파일 currentImage = 새 파일 (store_dir, image_name); if (! currentImage.exists ()) {system.out.println ( "그림이 존재하지 않는다"); 계속하다; } 긴 길이 = currentImage.length (); imageLength [ExecuteCount % imageLengthlength] = 길이; // JumpJumpHelper.CheckDorePlay ()를 다시 열어야하는지 확인하십시오. ExecuteCount ++; System.out.println ( "CurrentThrow" + ExecuteCount + "Execution!"); // 체커 및베이스 플레이트의 중앙 좌표를 가져옵니다 int [] result = jumpjumphelper.gethalmaandboardxyvalue (currentImage); if (result == null) {system.out.println ( "메소드의 결과 GethalmaandboardxyValue의 결과는 null!"); 계속하다; } int halmax = 결과 [0]; int halmay = 결과 [1]; int boardx = 결과 [2]; int boardy = 결과 [3]; System.out.println ( "Halmax :" + Halmax + ", Halmay :" + Halmay + ", Boardx :" + Boardx + ", Boardy :" + Boardy); // 점프의 거리를 계산합니다. Double Dougn JumpDistance = JumpJumphelper.computeJumpdistance (Halmax, Halmay, Boardx, Boardy); jumpjumphelper.dojump (점프 디스턴스); // TimeUnit.milliseconds.sleep (2500)마다 2.5 초 동안 머무 릅니다. }} catch (예외 e) {e.printstacktrace (); }} / ** * 다시 시작 해야하는지 확인하십시오 * * @author leeho * @update 2017 년 12 월 31 일 1:39:18 pm * / private void checkdoreplay () {if (imageLength [0]> 0 && imageLength [0] == imagelength [1] && imageLength [2] & imageLength [2] 0]. imageLength [2] imageLength [3] && imageLength [3] == imageLength [4]) {// 이미지 크기가 5 번 연속 동일 함을 의미합니다. 현재 화면이 다른 게임 배열에 있음을 알 수 있습니다 .fill (imageLength, 0); // 버튼을 시뮬레이션하고 클릭하여 게임을 시작합니다 (); }} / ** * 지정된 좌표의 RGB 값을 가져옵니다 * @param bufferedImage * @param x * @param y * @author leeho * @update 2017 년 12 월 31 일 오후 12시 12 분 43 초 * / private void processrgbinfo (버퍼링 버퍼 버퍼, int x) {the.rgbinfo.); 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; 프라이빗 int gvalue; 개인 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; }}}더 많은 내용을 보려면 학습 할 특별한 주제 "Jump On Wechat"을 참조하십시오.
위는이 기사의 모든 내용입니다. 모든 사람의 학습에 도움이되기를 바랍니다. 모든 사람이 wulin.com을 더 지원하기를 바랍니다.