Skip to content

Instantly share code, notes, and snippets.

@billynyh
Created November 9, 2012 04:27
Show Gist options
  • Save billynyh/4043695 to your computer and use it in GitHub Desktop.
Save billynyh/4043695 to your computer and use it in GitHub Desktop.
android monkeyrunner screencap
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
import datetime
def capture_and_save(fname):
device = MonkeyRunner.waitForConnection()
snapshot = device.takeSnapshot()
snapshot.writeToFile(fname)
def capture(prefix=""):
d = datetime.datetime.now()
fname = d.strftime("%Y%m%d-%H%M%S.png")
if prefix:
fname = prefix + fname
capture_and_save(fname)
capture()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment