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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
| import os import time
def runADB(cmd, wait_time=1): os.system(cmd) time.sleep(wait_time)
def listDev(): runADB("adb devices", 0)
def putFile(local_path, remote_path): cmd = "adb push {local_path} /sdcard/{remote_path}" runADB(cmd.format(**locals()))
def getFile(remote_path, local_path): cmd = "adb pull /sdcard/{remote_path} {local_path}" runADB(cmd.format(**locals()))
def installApk(local_apk_path): cmd = "adb install {local_apk_path}" runADB(cmd.format(**locals()))
def tap(x, y, wait_time=1): cmd = "adb shell input tap {x} {y}" runADB(cmd.format(**locals()), wait_time)
def longTap(x, y): swipe(x, y, x, y, 1000)
def swipe(startX, endX, startY, endY, timeToSwipe): cmd = "adb shell input swipe {startX} {startY} {endX} {endY} {timeToSwipe}" runADB(cmd.format(**locals()))
def swipeUp(): swipe(100, 400, 100, 100, 300)
def swipeDown(): swipe(100, 100, 100, 400, 300)
def keyevent(num): cmd = "adb shell input keyevent {num}" runADB(cmd.format(**locals()))
def back(): keyevent(4)
def home(): keyevent(3)
def enter(): keyevent(66)
def esc(): keyevent(111)
def intent(intent_name, paras): cmd = "adb shell am start -a {intent_name} -d {paras}" runADB(cmd.format(**locals()))
def call(phone): intent("android.intent.action.CALL", phone)
def web(url): intent("android.intent.action.VIEW", url)
# {包名}/.{主Activity名} def launch(app): cmd = "adb shell am start -n {app} " runADB(cmd.format(**locals()))
def listPkg(): cmd = "adb shell pm list package " runADB(cmd)
def screenshot(filename): cmd = "adb shell screencap /sdcard/{filename}.png " runADB(cmd.format(**locals()))
def screenshotToPC(local_path, filename): screenshot(filename) getFile("/sdcard/"+filename+".png", local_path) cmd = "adb shell rm /sdcard/{filename}.png" runADB(cmd.format(**locals()))
def ershida(): # tap(360, 930) # 人机 # loop tap(360, 980, 5) # 开始
tap(360, 710, 5) # A tap(360, 840, 5) # B tap(360, 710, 5) # A tap(360, 840, 5) # B tap(360, 710, 5) # A tap(360, 930, 3) # 继续挑战
# tap(360, 710, 5) # A # tap(360, 840, 5) # B # tap(360, 980, 5) # C # tap(360, 1120, 5) # D
def ershida10(): tap(360, 930) # 人机 for i in range(10): print(i) ershida()
if __name__ == '__main__': runADB("adb version", 0)
# from PhoneADB import *
|