Java微信跳一跳操作指南
Java微信跳一跳操作指南,指哪挑哪。
本文的思路是通過adb來控制手機進行操作,通過java寫一個jframe覆蓋在手機屏幕上,用鼠標獲取跳的起點和終點,經(jīng)過試驗獲取跳的jframe距離和按壓時長的關系(線性關系),然后通過adb來根據(jù)計算出的結(jié)果操作按下時長,(此處還需要一個第三方工具來實時把畫面?zhèn)魉徒o電腦,將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);
}
這里的系數(shù)需要自己通過不斷測試來調(diào)整,即最后那個系數(shù)4.6 可自行調(diào)整:
String cmd = "adb shell input touchscreen swipe 170 187 170 187 "+Math.round(dis*4.6);
操作方法很簡單,鼠標右鍵點擊一次當前棋子所在位置,然后鼠標右鍵再點一次落點位置。
更多內(nèi)容大家可以參考專題《微信跳一跳》進行學習。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
解決SpringBoot中MultipartResolver和ServletFileUpload的沖突問題
這篇文章主要介紹了解決SpringBoot中MultipartResolver和ServletFileUpload的沖突問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-10-10
SpringBoot使用CommandLineRunner和ApplicationRunner執(zhí)行初始化業(yè)務方式
這篇文章主要介紹了SpringBoot使用CommandLineRunner和ApplicationRunner執(zhí)行初始化業(yè)務方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-08-08
java如何根據(jù)提供word模板導出word文檔詳解
在日常的開發(fā)工作中,我們時常會遇到導出Word文檔報表的需求,比如公司的財務報表、醫(yī)院的患者統(tǒng)計報表、電商平臺的銷售報表等等,這篇文章主要給大家介紹了關于java如何根據(jù)提供word模板導出word文檔的相關資料,需要的朋友可以參考下2023-09-09
Maven添加Tomcat插件實現(xiàn)熱部署代碼實例
這篇文章主要介紹了Maven添加Tomcat插件實現(xiàn)熱部署代碼實例,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-04-04
springboot中使用FastJson解決long類型在js中失去精度的問題
這篇文章主要介紹了springboot中使用FastJson解決long類型在js中失去精度的問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-06-06
Java實現(xiàn)的簡單數(shù)字處理類及用法示例
這篇文章主要介紹了Java實現(xiàn)的簡單數(shù)字處理類及用法,涉及java數(shù)字運算相關操作技巧,需要的朋友可以參考下2018-01-01

