import os
a=‘launcher’
date = os.popen(“adb shell dumpsys window | findstr mCurrentFocus”,“r”)#获取当前运行的进程和activity
mCurrentFocus = date.read()#读取date并赋值给mCurrentFofus
date.close()
list1 = mCurrentFocus.split(’ ‘)
list2 = list1[-1]
list3 = list2.split(’/’)
process = list3[0]#拿到包名
activity = list3[-1]#拿到activity
if a in activity:#通过和activity对比判断当前是否在桌面
a=‘launcher’
else:
os.system("adb shell am force-stop "+ process)#不在桌面执行杀进程
清除数据同理脚本改成adb shell pm clear "+ process即可
获取当前运行APP包名并杀掉进程或者清除数据
最新推荐文章于 2024-04-30 19:24:04 发布