微信小程式跳一跳java程式碼手動刷分程式碼教程
阿新 • • 發佈:2019-01-23
//建立視窗
//建構函式
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();
}
}
}
}
});
}