adb 脚本

1、打印可以ping到的IP地址

@echo off
set a=1
:start
echo %a% \把a打印到shell
ping 172.19.5.%a% -w 1 -n 1|find /i "Lost = 1"&&set c=1||set c=0
if %c%==0 (echo 172.19.5.%a% >>IP.txt) \ 把ip地址保存到IP.txt
set /a a=%a%+1
if %a%==255 exit
goto :start

2、adb 脚本语法

set b=1
:1
if %b% equ b exit
adb shell input tap 581 266
adb shell input tap 1185 266 \ 坐标
adb shell sleep 15 \暂停
adb shell input swipe 100 100 200 200 200 \坐标及时间
set /a b+=1
goto 1

3、想要让一个bat脚本无限循环可以效仿1、2或者在脚本末尾添加   %0

@ echo off
set b = 11
adb shell input tap 952 445
adb shell input text WWww@#123124 
adb shell input tap 1781 391
set /a b+=1
adb shell sleep 0.5
adb shell screencap -p /sdcard/screen.png
adb pull /sdcard/screen.png C:Usersv-wutaotaoDesktopqhidtest%b%screen.png
%0

4、android设备截图并保存在本地

adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png D:pngscreenshot.png
set d=%date:~0,10%
set filename=%date:~0,10%_%time:~0,2%_%time:~3,2%_%time:~6,2%.png
set filename=%filename:/=-%
echo %filename%
ren D:pngscreenshot.png %filename%
REM pause

........未完待续.....

原文地址:https://www.cnblogs.com/wutaotaosin/p/9647966.html