Java WeChat jump operation guide, pointing to wherever you choose.
The idea in this article is to control the operation of the mobile phone through adb, write a jframe to cover the mobile phone screen through java, use the mouse to obtain the starting point and end point of the jump, and obtain the relationship (linear relationship) between the distance of the jump and the pressing time (linear relationship), and then use adb to operate the pressing time according to the calculated results (a third-party tool is also needed here to transmit the screen to the computer in real time and overwrite the jframe on the screen on the computer).
The code is very short, as follows:
package jump;import java.awt.FlowLayout;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import javax.swing.JFrame;import javax.swing.JLabel;@SuppressWarnings("serial")public class JumpJump extends JFrame{ private JLabel label; boolean flag=false; int x0,y0,x1,y1; public JumpJump(){ super("WeChat jump");//Create a new window this.setUndecorated(true); this.setOpacity(0.7f); this.setSize(320,580);//Set this.setVisible(true);//Visible//This.dispose(); this.setLocationRelativeTo(null); this.toFront(); this.setLayout(new FlowLayout(FlowLayout.CENTER)); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JLabel label = new JLabel("right click"); this.add(label); this.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ if(e.getButton() == MouseEvent.BUTTON3){ //3 represents right-click if(!flag) { x0 = e.getX(); y0 = e.getY(); String banner = "The coordinates of the current click position of the mouse are " + x0 + "," + y0; label.setText(banner); flag=true; } else { x1=e.getX(); y1=e.getY(); double _x = Math.abs(x0 - x1); double _y = Math.abs(y0 - y1); double dis=Math.sqrt(_x*_x+_y*_y); label.setText(Math.ceil(dis)*4.8+""); flag=false; String cmd = "adb shell input touchscreen swipe 170 187 170 187 "+Math.round(dis*4.6); Runtime run = Runtime.getRuntime(); try { Process pr = run.exec(cmd); System.out.println(cmd); pr.waitFor(); } catch (Exception e1) { e1.printStackTrace(); System.out.println(e1); } } } } } } }); } public static void main(String[] args) { new JumpJump(); }}The following code sets transparency:
this.setUndecorated(true); this.setOpacity(0.7f);
x0 y0 is the coordinate of the point that the mouse clicks for the first time, and x1 y1 is the second coordinate. It is determined by flag whether it is the first or second click.
This paragraph is a code to control cmd operations, so you don’t have to type it in cmd every time:
String cmd = "adb shell input touchscreen swipe 170 187 170 187 "+Math.round(dis*4.6); Runtime run = Runtime.getRuntime(); try { Process pr = run.exec(cmd); System.out.println(cmd); pr.waitFor(); } catch (Exception e1) { e1.printStackTrace(); System.out.println(e1); }The coefficients here need to be adjusted by themselves through continuous testing, that is, the last coefficient 4.6 can be adjusted by itself:
String cmd = "adb shell input touchscreen swipe 170 187 170 187 "+Math.round(dis*4.6);
The operation method is very simple. Right-click the current position of the chess piece once, and then right-click the landing position again.
For more content, you can refer to the special topic "Jump on WeChat" to learn.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.