Skip to content

Instantly share code, notes, and snippets.

@tian2992
Created January 2, 2013 00:06
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tian2992/4431155 to your computer and use it in GitHub Desktop.
Save tian2992/4431155 to your computer and use it in GitHub Desktop.
An Android monkeyrunner based remote control. Thanks to Jython and Swing. Should be executed from the monkeyrunner REPL
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage
device = MonkeyRunner.waitForConnection()
from javax.swing import JButton, JFrame, JPanel, ImageIcon
frame = JFrame('Android Display!',
defaultCloseOperation = JFrame.EXIT_ON_CLOSE,
size = (960, 540)
)
def change_text(event):
print 'Clicked!'
def mouseUsageClicked(event):
x = event.getX() * 2
y = event.getY() * 2
print(str(x)+"-"+str(y))
device.touch(x,y,MonkeyDevice.DOWN_AND_UP)
paintScreenshot(pan)
def paintScreenshot(p):
result = device.takeSnapshot()
im = ImageIcon(result.convertToBytes())
p.graphics.drawImage(im.getImage(), 0, 0, 960, 540, p)
pan = JPanel(mouseClicked=mouseUsageClicked) #, super__paintComponent= paintScreenshot)
frame.add(pan)
frame.visible = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment