I'm using this following script to take screenshots:
def snap():
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
print "Waiting for device.."
device = MonkeyRunner.waitForConnection()
print "Device found.."
result = device.takeSnapshot()
print "Clicked.."
now = datetime.datetime.now()
file = "C:\\Workspace\\"+now.strftime("%d%m%Y-%H%M%S")+".png"
result.writeToFile(file,'png')
print file
I've put this in a while loop and it works fine for one screenshot. But after that one screenshot, the output hangs like this infintely:
C:\Program Files\Android\android-sdk\tools>monkeyrunner C:\Workspace\snap.py
Click (y/n)?y
User said: y
Calling function..
Waiting for device..
Device found..
Clicked..
C:\Workspace\19042011-155124.png
Click (y/n)?y
User said: y
Calling function..
Waiting for device..
How do I keep the code from blocking up and keep taking screenshots? Is this a device-memory issue?
Move device = MonkeyRunner.waitForConnection()
out of the loop and keep the connection with your device open.