时间:2021-07-01 10:21:17 帮助过:61人阅读
这里使用python编写一个截屏的脚本,双击运行脚本就OK,截屏成功后会将截屏文件已当前时间命名,并保存在存放脚本的当前路径的screenshot文件夹下:
#!/usr/bin/env python import os import time PATH = lambda p: os.path.abspath(p) def screenshot(): path = PATH(os.getcwd() + "/screenshot") timestamp = time.strftime('%Y-%m-%d-%H-%M-%S',time.localtime(time.time())) os.popen("adb wait-for-device") os.popen("adb shell screencap -p /data/local/tmp/tmp.png") if not os.path.isdir(PATH(os.getcwd() + "/screenshot")): os.makedirs(path) os.popen("adb pull /data/local/tmp/tmp.png " + PATH(path + "/" + timestamp + ".png")) os.popen("adb shell rm /data/local/tmp/tmp.png") print "success" if __name__ == "__main__": screenshot()