国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

安卓版微信跳一跳輔助 跳一跳輔助Java代碼

2019-10-22 18:17:28
字體:
供稿:網(wǎng)友

安卓版微信跳一跳輔助,java實(shí)現(xiàn),具體內(nèi)容如下

微信跳一跳輔助,安卓版本微信跳一跳,微信跳一跳,Java代碼

已經(jīng)看到網(wǎng)上有大神用各種方式實(shí)現(xiàn)了,我這是屬于簡易版ADB命令式實(shí)現(xiàn)。

操作方法

1.光標(biāo)移動到起始點(diǎn),點(diǎn)擊FORM
2.光標(biāo)移動到目標(biāo)點(diǎn),點(diǎn)擊TO
3.小人已經(jīng)跳過去了

原理說明

安裝APP,通過設(shè)置起點(diǎn)和目標(biāo)點(diǎn)位置,獲得彈跳的毫秒數(shù),發(fā)送請求到連接手機(jī)的電腦中,電腦執(zhí)行adb命令起跳。

具體實(shí)現(xiàn)

本人的測試設(shè)備是Mate9,android版本為7.0,由于在非Root環(huán)境下,普通安卓應(yīng)用并不能通過Runtime.getRuntime().exec()來點(diǎn)擊本應(yīng)用外的區(qū)域,所以將手機(jī)直接通過USB調(diào)試模式連接到電腦,在點(diǎn)擊TO按鈕后,

int a = Math.abs(mToX - mFromX);int b = Math.abs(mToY - mFromY);double c = Math.sqrt(a * a + b * b);

已知起點(diǎn)和終點(diǎn)的坐標(biāo),得到兩條直角邊長度,用勾股定理很容易就求出了斜邊長度,經(jīng)過測試,mate9每ms的彈跳距離是0.75像素,長度除0.75得到time的毫秒數(shù),直接發(fā)起一次GET請求到電腦中發(fā)布的Servlet,然后電腦執(zhí)行Runtime.getRuntime().exec("adb shell input swipe 100 100 100 100 " + time)來控制起跳,一次完美的起跳就完成了。

源代碼

源代碼非常簡單,就直接放在這里了

//寫在安卓APP中的起跳public class Jump {private static final String TAG = "Jump";private Context mContext;private int mFromX = 0;private int mFromY = 0;private int mToX = 0;private int mToY = 0;/** * 每毫秒的距離 */private static final double MS_DISTANCE = 0.75;private WindowManager wm;private View mIndicatorView;private View mIndicator;private WindowManager.LayoutParams params;private TextView mTv_time;public Jump(Context context) { mContext = context; init();}private void init() { wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); mIndicatorView = LayoutInflater.from(mContext).inflate(R.layout.indicator, null, false); mIndicatorView.measure(0, 0); mIndicator = mIndicatorView.findViewById(R.id.indicator); mTv_time = mIndicatorView.findViewById(R.id.tv_time); mIndicatorView.findViewById(R.id.btnForm) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {  setForm(); } }); mIndicatorView.findViewById(R.id.btnTo) .setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) {  setTo(); } }); mIndicatorView.setOnTouchListener(new View.OnTouchListener() { int startX; int startY; @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN:  startX = (int) event.getRawX();  startY = (int) event.getRawY();  break; case MotionEvent.ACTION_MOVE:  int newX = (int) event.getRawX();  int newY = (int) event.getRawY();  int dx = newX - startX;  int dy = newY - startY;  params.x += dx;  params.y += dy;  wm.updateViewLayout(mIndicatorView, params);  startX = (int) event.getRawX();  startY = (int) event.getRawY();  break; default:  break; } return true; } }); params = new WindowManager.LayoutParams(); params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; params.format = PixelFormat.TRANSLUCENT; params.gravity = Gravity.TOP + Gravity.LEFT; params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; wm.addView(mIndicatorView, params);}public void setForm() { int[] mLocation = new int[2]; mIndicator.getLocationOnScreen(mLocation); int wOffset = mIndicator.getMeasuredWidth() / 2; int hOffset = mIndicator.getMeasuredHeight() / 2; mFromX = mLocation[0] + wOffset; mFromY = mLocation[1] + hOffset;}public void setTo() { int[] mLocation = new int[2]; mIndicator.getLocationOnScreen(mLocation); int wOffset = mIndicator.getMeasuredWidth() / 2; int hOffset = mIndicator.getMeasuredHeight() / 2; mToX = mLocation[0] + wOffset; mToY = mLocation[1] + hOffset; int a = Math.abs(mToX - mFromX); int b = Math.abs(mToY - mFromY); double c = Math.sqrt(a * a + b * b); final int time = (int) (c / MS_DISTANCE); mTv_time.setText(String.valueOf(time)); mFromX = 0; mFromY = 0; mToX = 0; mToY = 0; new Thread(new Runnable() { @Override public void run() { requestGet(time); } }).start();}private void requestGet(int time) { try { StringBuilder requestUrl = new StringBuilder("http://192.168.1.140:8080/jump/JumpTime").append("?").append("time=").append(time); // 新建一個URL對象 URL url = new URL(requestUrl.toString()); // 打開一個HttpURLConnection連接 HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); // 設(shè)置連接主機(jī)超時時間 urlConn.setConnectTimeout(5 * 1000); //設(shè)置從主機(jī)讀取數(shù)據(jù)超時 urlConn.setReadTimeout(5 * 1000); // 設(shè)置是否使用緩存 默認(rèn)是true urlConn.setUseCaches(true); // 設(shè)置為Post請求 urlConn.setRequestMethod("GET"); //urlConn設(shè)置請求頭信息 //設(shè)置請求中的媒體類型信息。 urlConn.setRequestProperty("Content-Type", "application/json"); //設(shè)置客戶端與服務(wù)連接類型 urlConn.addRequestProperty("Connection", "Keep-Alive"); // 開始連接 urlConn.connect(); // 判斷請求是否成功 if (urlConn.getResponseCode() == 200) { // 獲取返回的數(shù)據(jù) Log.e(TAG, "Get方式請求成功,result--->"); } else { Log.e(TAG, "Get方式請求失敗"); Log.e(TAG, urlConn.getResponseMessage()); } // 關(guān)閉連接 urlConn.disconnect(); } catch (Exception e) { Log.e(TAG, e.toString()); }}}

 

//標(biāo)靶的布局文件<FrameLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="wrap_content"android:layout_height="150dp"><RelativeLayout android:layout_width="100dp" android:layout_height="wrap_content"> <TextView android:id="@+id/tv_time" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true"/> <RelativeLayout android:id="@+id/rl" android:layout_width="100dp" android:layout_height="100dp" android:layout_below="@id/tv_time"> <View android:layout_width="match_parent" android:layout_height="1dp" android:layout_centerVertical="true" android:background="@android:color/black"/> <View android:layout_width="1dp" android:layout_height="match_parent" android:layout_centerHorizontal="true" android:background="@android:color/black"/> <View android:id="@+id/indicator" android:layout_width="30dp" android:layout_height="30dp" android:layout_centerInParent="true" android:background="@drawable/mid"/> </RelativeLayout> <Button android:id="@+id/btnForm" android:layout_width="50dp" android:layout_height="wrap_content" android:layout_below="@id/rl" android:onClick="setForm" android:text="form" android:textSize="8sp"/> <Button android:id="@+id/btnTo" android:layout_width="50dp" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_below="@id/rl" android:onClick="setTo" android:text="to" android:textSize="8sp"/></RelativeLayout></FrameLayout>
//Servlet文件public class Jump extends HttpServlet {@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { int time = Integer.parseInt(req.getParameter("time")); Runtime.getRuntime().exec("adb shell input swipe 100 100 100 100 " + time);}}

以上就是此Java版跳一跳輔助的核心內(nèi)容,從此制霸排行榜不是夢φ(>ω<*)--->(告訴一個秘密:跳太多分?jǐn)?shù)會被直接刪除的喲  ̄へ ̄)

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。


注:相關(guān)教程知識閱讀請移步到Android開發(fā)頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 莒南县| 漳浦县| 苏尼特左旗| 河东区| 木里| 桃园市| 马山县| 顺义区| 平塘县| 洛隆县| 旬邑县| 东辽县| 容城县| 城步| 河北区| 久治县| 监利县| 九江市| 永嘉县| 黄浦区| 上杭县| 普陀区| 简阳市| 巴彦淖尔市| 泰安市| 张北县| 霍山县| 瓮安县| 娄烦县| 宣武区| 三江| 张家口市| 开封市| 彩票| 马边| 铜鼓县| 名山县| 和顺县| 永登县| 阜新市| 红原县|