按键精灵封装安卓模拟器命令源码
1、测试代码:
2、TracePrint("***************安卓模拟器接口测试*************")
返回值 = Lib.LDAPI.初始化数据()
Dim playerList,playerInfos,i
playerList = Lib.LDAPI.取模拟器列表()
TracePrint("解析模拟器信息:")
For i = 0 To UBound(playerList)
playerInfos = Split(playerList(i), ",")
3、 Dim index, name,mainFrame, renderFrame, isRunning, progressID, vboxProgressID
index = playerInfos(0) //索引
name = playerInfos(1) //标题
mainFrame = playerInfos(2) //主窗口句柄
renderFrame = playerInfos(3) //安卓窗口句柄, 需要绑定的
isRunning = playerInfos(4) //是否已经启动(进入了安卓系统)
progressID = playerInfos(5) //进程ID
vboxProgressID = playerInfos(6) //Vbox进程
TracePrint("索引:" & index &" 标题:" & name&" 主窗口句柄:" & mainFrame&" 安卓窗口句柄:" & renderFrame&" 是否启动:" & isRunning&" 进程ID:" & progressID&" VBox进程:" & vboxProgressID)
Next
4、//启动模拟器0
Lib.LDAPI.启动 (0)
Delay(5000)
//启动App
返回值 = Lib.LDAPI.启动App(0, "com.tencent.tmgp.cf")
//关闭模拟器
//Lib.LDAPI.关闭 ("安卓模拟器")
//判断是否启动
返回值 = Lib.LDAPI.是否正在运行(1)
TracePrint ("模拟器1是否已经启动:" & 返回值)
Delay(5000)
返回值 = Lib.LDAPI.标题到索引("雷电模拟器-1")
TracePrint ("安卓模拟器-1 的索引是:" & 返回值)
Delay(5000)
//设置(不需要的项用0代替)
返回值 = Lib.LDAPI.设置基本属性(0,800,800,220,2,0)
Delay (5000)
5、//ADB命令
返回值 = Lib.LDAPI.执行ADB命令(0, "shell pm list packages")
Delay(5000)
//执行LD命令(跟adb一样的东东, 比adb稳定)
返回值 = Lib.LDAPI.执行LD命令(0,"pm list packages -f")
//action命令
//摇一摇
Delay(5000)
TracePrint("执行摇一摇:")
返回值 = Lib.LDAPI.action(0, "call.shake", "null")
//按返回键
Delay(5000)
TracePrint("执行返回键:")
返回值 = Lib.LDAPI.action(0,"call.keyboard","back")
//
Delay(5000)
TracePrint("设置imei为自动:")
返回值 = Lib.LDAPI.SetProp(0, "phone.imei", "auto")
Delay(5000)
返回值 = Lib.LDAPI.GetProp(0,"phone.imei")
//定位
Delay(5000)
返回值 = Lib.LDAPI.定位(0,80,60)
//
Delay(5000)
返回值 = Lib.LDAPI.降CPU侦(0,20)
6、执行结果:
7、接口图: