Created
January 2, 2013 00:06
-
-
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
This file contains hidden or 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
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