Created
February 10, 2012 20:18
-
-
Save printminion/1792428 to your computer and use it in GitHub Desktop.
Android Monkeyrunner - photo_monkey.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a monkeyrunner jython script that opens a connection to an Android | |
# device and starts camera app and makes photos by touching the camerabutton. | |
# | |
# See http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html | |
# | |
# usage: monkeyrunner photo_monkey.py | |
# | |
# Imports the monkeyrunner modules used by this program | |
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice | |
# Connects to the current device | |
device = MonkeyRunner.waitForConnection() | |
# sets a variable with the package's internal name | |
package = 'com.android.camera' | |
# sets a variable with the name of an Activity in the package | |
activity = 'com.android.camera.Camera' | |
# sets the name of the component to start | |
runComponent = package + '/' + activity | |
# Runs the component | |
device.startActivity(component=runComponent) | |
# Position of the button | |
#x = 62 | |
#y = 721 | |
x = 722 | |
y = 414 | |
pause = 5 | |
for i in range(1, 4): | |
# Every so often inject a touch to spice things up! | |
device.touch(x, y, 'DOWN_AND_UP') | |
MonkeyRunner.sleep(pause) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment