monkeyrunner 截图

上一篇 / 下一篇  2015-04-08 17:32:57 / 个人分类:monkeyrunner


#! /usr/bin/env monkeyrunner 

# coding=gbk
import sys 
# Imports the monkeyrunner modules used by this program 
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice, MonkeyImage 
# Connects to the current device, returning a MonkeyDevice object 
device = MonkeyRunner.waitForConnection() 
if not device: 
   print >> sys.stderr, "Couldn't get connection" 
   sys.exit(1)

MonkeyRunner.sleep(1.5)
result = device.takeSnapshot()
MonkeyRunner.sleep(1.5)
result.writeToFile( 'C:\\' + sys.argv[1] + '.png','png')
——————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

将以上内容保存为:jietu.py
运行monkeyrunner jietu.py jietu001

就是将手机此时的状态截屏,将图片保存在电脑的c盘,并且图片的名字为jietu001.png
sys.argv[1]实现了图片名的支持 以参数形式传入



TAG: 图片名参数传入 截屏

 

评分:0

我来说两句

Open Toolbar