2025-05-19 19:36:35 +08:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
|
|
import uiautomator2 as u2
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
def clear_all_apps():
|
|
|
|
|
d = u2.connect()
|
|
|
|
|
while True:
|
|
|
|
|
try:
|
|
|
|
|
d.keyevent("HOME")
|
|
|
|
|
d.keyevent("HOME")
|
2025-09-01 17:10:09 +08:00
|
|
|
d.keyevent("312")
|
2025-05-19 19:36:35 +08:00
|
|
|
time.sleep(1)
|
|
|
|
|
if "com.miui.home:id/recents_container" not in d.dump_hierarchy():
|
|
|
|
|
continue
|
|
|
|
|
if "近期没有任何内容" in d.dump_hierarchy():
|
|
|
|
|
d.keyevent("HOME")
|
|
|
|
|
d.keyevent("HOME")
|
|
|
|
|
exit(0)
|
|
|
|
|
d.xpath('//*[@resource-id="com.miui.home:id/clearAnimView"]').click_exists(timeout=3)
|
|
|
|
|
d.keyevent("HOME")
|
|
|
|
|
d.keyevent("HOME")
|
|
|
|
|
except Exception as e:
|
|
|
|
|
print("clear_all_apps errors", e)
|
|
|
|
|
d = u2.connect()
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
if __name__=="__main__":
|
|
|
|
|
clear_all_apps()
|