Java微信跳一跳操作指南

2025-05-29 0 20

Java微信跳一跳操作指南,指哪挑哪。

本文的思路是通过adb来控制手机进行操作,通过java写一个jframe覆盖在手机屏幕上,用鼠标获取跳的起点和终点,经过试验获取跳的jframe距离和按压时长的关系(线性关系),然后通过adb来根据计算出的结果操作按下时长,(此处还需要一个第三方工具来实时把画面传送给电脑,将jframe覆盖在电脑上的画面上)。

代码很短,如下:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72
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();

}

}

下面这段代码是设置透明度的:

?

1

2
this.setUndecorated(true);

this.setOpacity(0.7f);

x0 y0是鼠标第一次点击的点的坐标,x1 y1是第二次坐标, 通过flag判断是 第一次还是第二次点击。

这一段是代码控制cmd操作,就不用自己在cmd里每次输入了:

?

1

2

3

4

5

6

7

8

9

10

11

12
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 可自行调整:

?

1
String cmd = "adb shell input touchscreen swipe 170 187 170 187 "+Math.round(dis*4.6);

操作方法很简单,鼠标右键点击一次当前棋子所在位置,然后鼠标右键再点一次落点位置。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持快网idc。

原文链接:http://blog.csdn.net/zr915/article/details/78962044

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

快网idc优惠网 建站教程 Java微信跳一跳操作指南 https://www.kuaiidc.com/113263.html

相关文章

发表评论
暂无评论