微信跳一跳入門

1 手機和電腦用數據線鏈接

 

鏈接android手機,首先電腦和手機都要安裝360手機助手,而後手機要開usb調試模式python

 

1.adb devices   查看設備是否連上android

 

2.adb shell dumpsys window displays   查看設備分辨率shell

 

3. adb shell wm density   查看屏幕密度ui

 

4.adb shell getprop ro.product.device   查看手機型號命令行

 

5.adb shell getprop ro.build.version.release  查看android版本3d

 

2.查看手機目錄路徑

adb shell ls -l調試

 

能夠看到sdcard指向的是相對路徑blog

用adb shell進入shell命令行模式,輸入ls /storage/列舉出手機的絕對路徑事件

 

3.截屏

adb shell screencap –p /storage/sdcard1/image/1.png圖片

 

將手機文件拷貝到電腦f盤

adb pull /storage/sdcard1/image/1.png f:\

 

 

4.屏幕點擊事件

經過以下命令模擬手機的滑動事件

adb shell input swipe x1 y1 x2 y2 duration

 

x1,y1是滑動開始的點;x2,y2是滑動結束的點;durarion:持續的時間(ms);x1,y1和x2,y2相同,則表示長按

 

例:adb shell input swipe 100 100 100 100 700     經過截屏來顯示效果。

 

5.跳幾步

(1)    進入python命令行

(2)    Import os

(3)    for i in range(3):

    os.system(‘adb shell input swipe 100 100 100 100 700’)

 

6.實驗截圖

   

7. duration值的計算

 

 

從圖中能夠看到,時間的值跟開始位置到結束位置的距離有關。

假設時間是t,距離是s。公式應該是s = at

基本思路:兩點之間的距離乘以一個時間係數。

因此要從截圖上識別出起跳位置的座標(x1,y1)和目標位置的座標(x2,y2)。

起跳位置的座標:小人的底座中心點

目標位置的座標:目標菱形的中心點

而後計算這兩點之間的距離(歐氏距離):sqrt((x1-x2)2+(y1-y2)2)

8.顯示圖片

相關文章
相關標籤/搜索