Android下monkey使用脚本

上一篇 / 下一篇  2012-09-21 18:35:31 / 个人分类:Android


1、脚本使用方法
#adb shell
#monkey -f **.script. times
说明:
1)、脚本位置可以是绝对位置,也可以是相对位置(cd进入相应的目录)
2)、times指脚本执行的次数

2、脚本的内容示例(源码修正版)
  //header
      type= raw events
      count= 10
      speed= 1.0
  //line at the end of the header means that below it is the context of script
      start data >>
      DispatchPointer(5109520,5109520,0,230.75429,458.1814,0.20784314,
          0.06666667,0,0.0,0.0,65539,0)
      DispatchKey(5113146,5113146,0,20,0,0,0,0)
      DispatchFlip(true)
      ...
说明:
1)、前3行是脚本头
2)、后3行是脚本内容,每行为一个函数

3、常用函数介绍
以下列表提炼于源码MonkeySourceScript.java

DispatchKey(downTime,eventTime,action,code,repeat,metaState,device,scancode)
      @param long downTime  //键最初被按下的时间
      @param long eventTime  //事件发生的时间                   
      @param int action  //(ACTION_DOWN=0,ACTION_UP=1,ACTION_MULTIPLE=2)
      @param int code  //键值,比如KEYCODE_DPAD_DOWN(20)
      @param int repeat  //
      @param int metaState  //当前按下的meta键的标识
      @param int device  //事件发生的设备id
      @param int scancode  //
DispatchPointer(downTime, eventTime,action, x, y, pressure, size, metaState,                               xPrecision,yPrecision,device, edgeFlags)
      @param long downTime  //键最初被按下的时间
      @param long eventTime  //事件发生的时间                   
      @param int action  //(ACTION_DOWN=0,ACTION_MOVE=1,ACTION_UP=2,ACTION_CANCEL=3)
      @param float x  //x坐标
      @param float y  //y坐标
      @param float pressure  //当前事件的压力,范围0-1
      @param float size  //触摸的近似值,范围0-1
      @param int metaState  //当前按下的meta键的标识
      @param float xPrecision  //x坐标精确值
      @param float yPrecision  //y坐标精确值
      @param int device  //事件来源,范围0-x,0表示不来自物理设备
      @param int sedgeFlags  //
DispatchTrackball(downTime, eventTime,action, x, y, pressure, size, metaState,                              xPrecision,yPrecision,device, edgeFlags)
Tap(x,y,duration);
DispatchPress(String key_name) 
DispatchFlip(boolean keyboardOpen)     
UserWait(long sleeptime)   
LaunchActivity(String pkg_name, String cl_name,long alarmTime)    
UserWait(long sleeptime)    
LongPress()


TAG: Android android Monkey monkey script Script

 

评分:0

我来说两句

Open Toolbar