The process of testing often need to intercept the screen, the usual practice is to use the phone's own screenshot function, and then copy the screenshot file, the advantage of this method is no need to connect the data line can be screenshots, the disadvantage is that the resulting screenshot file naming is randomly named, copying out is also more troublesome. Another way is to use the PC-side of the phone helper class software.
Here, using Python to write a screenshot of the script, double-click to run the script is OK, the screenshot will be successful after the screenshot file is the current time named, and saved in the current path of the script to 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 (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 ()