The process of testing often requires intercepting the screen, the usual approach is to use the phone's own screen-cutting function, and then the screen file copied out, the advantage of this method is not required to connect the data line can be screenshots, the disadvantage is that the resulting screenshot file name is randomly named, copy out also more trouble. Another way is to use the PC-side phone helper software.
Here use Python to write a screenshot of the script, double-click the run script is OK, screen after the success of the screenshot file has the current time name, and save the script in the current path of the screenshot folder:
#!/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 ( ))
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 "Succe SS "
If __name__ = =" __main__ ":
screenshot ()