adb

微信小游戏“跳一跳”,为了刷分数,写一个游戏辅助工具。

程序中使用的工具

1.ADB驱动,这个需要配置环境变量

2.http://download.youkuaiyun.com/download/lt_zl/10201117

第二个和第三个程序一个是手机上的,一个是电脑上的。打开USB调试。

这三个资源有链接;

3.cmd命令中使用adb命令

adb环境变量配置好之后,在cmd中输入"adb shell" 会出现一个"$",表示环境没有问题.

adb shell input touchscreen swipe 180 178 180 178 1000;
//这个命令时模拟手机的点击时间,最后一个参数是时间参数(单位是毫秒)
4.java代码

//cmd命令
String cmd ="adb shell input touchscreen swipe 180 187 180 187 "+Math.round(sqrt*6);
Runtime runtime  = Runtime.getRuntime();
//执行命令
try {
Process p = runtime.exec(cmd);
System.out.println(cmd);
int waitFor = p.waitFor();
System.out.println("waitFor:"+waitFor);
							
//读取标准输入流
nputStream iStream = p.getInputStream();
InputStreamReader iStreamReader = new InputStreamReader(iStream);
BufferedReader bReader = new BufferedReader(iStreamReader);
String readLine = bReader.readLine();
System.out.println("readLine:"+readLine);
							
InputStream errorStream = p.getErrorStream();
// 用一个读输出流类去读
InputStreamReader is = new InputStreamReader(errorStream);
// 用缓冲器读行
BufferedReader br1 = new BufferedReader(is);
String line1 = null;
StringBuilder sb1 = new StringBuilder();
line1 = br1.readLine();
System.out.println(line1);
 while ((line1 = br1.readLine()) != null) {
	System.out.println("---"+line1);
	sb1.append(line1);
}
System.out.println(sb1.toString());
errorStream.close();
System.out.println("end");
is.close();
br1.close();


} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
这边因为对RunTime不是太了解,所以最后程序没有跑通,希望有哦


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值