首先你得拿手机连接数据线连接电脑,
用到的还有TotalControl这个控制手机程序,还要一个adb来控制手机
TotalControl直接下载安装就可以比较简单,adb下载下来需要配置一下,
接下来就是java代码
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLabel;
public class jump2 extends JFrame{
int x0,y0,x1,y1;
boolean flag=false;
public static void main(String[] args) {
new jump2();
}
int x0,y0,x1,y1;
boolean flag=false;
public static void main(String[] args) {
new jump2();
}
//创建窗口
//构造函数
public jump2(){
super("微信跳一跳");
//设置窗口的大小
this.setSize(400, 805);
this.dispose();
//去除边框
this.setUndecorated(true);
//设置窗口是否可见
this.setVisible(true);
this.setOpacity(0.6f);
//设置一直最前
this.setAlwaysOnTop(true);
//设置居中
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//点击鼠标获取鼠标
//创建一个小面板
JLabel jlabel =new JLabel();
this.add(jlabel);
//给jlabel添加一个监听
this.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e){
System.out.println(e);
if(e.getButton()==MouseEvent.BUTTON1){
System.out.println("123");
if(!flag){
x0=e.getX();
y0=e.getY();
flag=true;
System.out.println("我"+x0+"是"+y0);
}else{
x1=e.getX();
y1=e.getY();
flag=false;
//取绝对值
double x3= Math.abs(x0-x1);
double y3= Math.abs(y0-y1);
//开平方
double dis= Math.sqrt(x3*x3+y3*y3);
System.out.println("dis是:"+dis);
//定义adb命令
String cmd=
"adb shell input touchscreen swipe 188 187 188 187 "+Math.round(dis*3);
Runtime run = Runtime.getRuntime();
System.out.println("run"+run);
try {
Process p= run.exec(cmd);
System.out.println(cmd);
p.waitFor();
System.out.println(p);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
});
}
//构造函数
public jump2(){
super("微信跳一跳");
//设置窗口的大小
this.setSize(400, 805);
this.dispose();
//去除边框
this.setUndecorated(true);
//设置窗口是否可见
this.setVisible(true);
this.setOpacity(0.6f);
//设置一直最前
this.setAlwaysOnTop(true);
//设置居中
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//点击鼠标获取鼠标
//创建一个小面板
JLabel jlabel =new JLabel();
this.add(jlabel);
//给jlabel添加一个监听
this.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e){
System.out.println(e);
if(e.getButton()==MouseEvent.BUTTON1){
System.out.println("123");
if(!flag){
x0=e.getX();
y0=e.getY();
flag=true;
System.out.println("我"+x0+"是"+y0);
}else{
x1=e.getX();
y1=e.getY();
flag=false;
//取绝对值
double x3= Math.abs(x0-x1);
double y3= Math.abs(y0-y1);
//开平方
double dis= Math.sqrt(x3*x3+y3*y3);
System.out.println("dis是:"+dis);
//定义adb命令
String cmd=
"adb shell input touchscreen swipe 188 187 188 187 "+Math.round(dis*3);
Runtime run = Runtime.getRuntime();
System.out.println("run"+run);
try {
Process p= run.exec(cmd);
System.out.println(cmd);
p.waitFor();
System.out.println(p);
} catch (Exception e2) {
e2.printStackTrace();
}
}
}
}
});
}
}
然后连接手机开始辅助玩跳一跳
ji