Java微信跳一跳操作指南
作者:zzzzzzzzr 时间:2022-07-06 11:14:36
Java微信跳一跳操作指南,指哪挑哪。
本文的思路是通过adb来控制手机进行操作,通过java写一个jframe覆盖在手机屏幕上,用鼠标获取跳的起点和终点,经过试验获取跳的jframe距离和按压时长的关系(线性关系),然后通过adb来根据计算出的结果操作按下时长,(此处还需要一个第三方工具来实时把画面传送给电脑,将jframe覆盖在电脑上的画面上)。
代码很短,如下:
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("微信跳一跳");//新建窗口
this.setUndecorated(true);
this.setOpacity(0.7f);
this.setSize(320,580);//宽高自设
this.setVisible(true);//可见
// this.dispose();
this.setLocationRelativeTo(null);
this.toFront();
this.setLayout(new FlowLayout(FlowLayout.CENTER));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel("右键点击");
this.add(label);
this.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
if(e.getButton() == MouseEvent.BUTTON3){ //3代表右键
if(!flag) {
x0 = e.getX();
y0 = e.getY();
String banner = "鼠标当前点击位置的坐标是" + 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();
}
}
下面这段代码是设置透明度的:
this.setUndecorated(true);
this.setOpacity(0.7f);
x0 y0是鼠标第一次点击的点的坐标,x1 y1是第二次坐标, 通过flag判断是 第一次还是第二次点击。
这一段是代码控制cmd操作,就不用自己在cmd里每次输入了:
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);
}
这里的系数需要自己通过不断测试来调整,即最后那个系数4.6 可自行调整:
String cmd = "adb shell input touchscreen swipe 170 187 170 187 "+Math.round(dis*4.6);
操作方法很简单,鼠标右键点击一次当前棋子所在位置,然后鼠标右键再点一次落点位置。
更多内容大家可以参考专题《微信跳一跳》进行学习。
来源:http://blog.csdn.net/zr915/article/details/78962044
标签:Java,微信,跳一跳
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
WPF自动隐藏的消息框的实例代码
2023-09-11 09:52:36
![](https://img.aspxhome.com/file/2023/2/79062_0s.gif)
C#实现餐厅管理系统
2023-11-27 16:05:05
spring cloud 之 客户端负载均衡Ribbon深入理解
2023-02-15 15:00:58
Android HorizontalScrollView滑动与ViewPager切换案例详解
2023-06-05 00:48:27
java单向链表的实现实例
2023-10-23 20:36:10
C#中把英文字母转换为大写或小写的方法
2021-06-13 18:46:55
c++ 虚继承,多继承相关总结
2022-11-19 12:09:35
![](https://img.aspxhome.com/file/2023/0/120810_0s.png)
利用stream实现一个简单的http下载器
2023-12-14 09:36:36
Android开发中使用外部应用获取SD卡状态的方法
2023-02-01 21:03:45
SpringBoot 实现自定义的 @ConditionalOnXXX 注解示例详解
2023-04-04 03:37:18
![](https://img.aspxhome.com/file/2023/3/62743_0s.jpg)
Java画笔的简单实用方法
2021-11-01 05:38:10
java实现文件夹解压和压缩
2022-06-07 03:00:39
java中Class.forName方法的作用详解
2021-07-08 21:47:31
Spring security如何重写Filter实现json登录
2023-09-15 13:33:31
Java与C++实现相同的MD5加密算法简单实例
2023-08-31 09:43:02
![](https://img.aspxhome.com/file/2023/2/60892_0s.jpg)
使用java实现猜拳小游戏
2023-11-25 17:30:16
![](https://img.aspxhome.com/file/2023/4/79224_0s.jpg)
java使用计算md5校验码方式比较两个文件是否相同
2023-05-10 23:43:16
SpringCloud Zuul基本使用方法汇总
2023-11-14 15:21:54
Android学习教程之日历控件使用(7)
2023-01-06 23:10:46
![](https://img.aspxhome.com/file/2023/6/123326_0s.jpg)
Java的Spring框架中bean的继承与内部bean的注入
2023-06-17 18:50:44
![](https://img.aspxhome.com/file/2023/9/69329_0s.png)