#打开cmd,使用adb connect 127.0.0.1:21503(逍遥模拟器),打开模拟器创建一个D:/log.log然后启动apk,然后ctrl+c去查看日志获取到apk的app_name 和app_activity
import time
import os
def open_app(app_name,app_activity):
msg = os.popen(
"adb shell ps | findstr" + app_name ).read().strip('\n')
if msg:
print("app 已经启动")
else:
os.system(
'adb shell am start -n' + app_name +app_activity)
print("app启动成功")
def operating():
flag = 1
while flag < 10000:
time.sleep(2)
os.system('adb shell input swipe 420 1035 420 186') #上滑
time.sleep(15) #停留多久自行定义
flag = flag + 1
if __name__ == '__main__':
open_app("com.android.contacts", "/com.android.packageinstaller.PackageInstallerActivity")
time.sleep(2)
operating()