前言:
前面放出过几次批处理,这次只放一个环境检查的被管理员给打回来了,不得不再找找几个有含金量的放出来,请看正文~~~
目录
1、Android环境检查 2、Android内存监控 3、模拟蓝牙手柄事件
一、Android环境检查
@ECHO OFF
ECHO. :::::::::::::::::::::::::::::::::::::::::::::::::
ECHO. :: ::
ECHO. :: 检查Android环境 ::
ECHO. :: ::
ECHO. :::::::::::::::::::::::::::::::::::::::::::::::::
::::::: 作者:Findyou ::
::::::: 版本:V1.0 时间:2014.01.03 ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO.
Color 0A
ECHO.┍┄┄┄┄┄┄┄┑
ECHO.┆ JAVA ┆
ECHO.┕┄┄┄┄┄┄┈┙
::0为成功,1为不成功,9009 命令不存在
java -version 2>nul
IF %ERRORLEVEL%==9009 (
Color 0D
ECHO. [ ERRO ] 检查JAVA环境: 未配置
ECHO. [ INFO ] 请参考指导配置环境变量
) ELSE (
ECHO. [ INFO ] 检查JAVA环境: 已配置
ECHO. -------------------------------------------------
java -version 2>java.txt
FOR /F "delims=" %%a IN ('FINDSTR /I /C:"version" java.txt') DO (
ECHO. [ INFO ] %%a
del /a/f/q java.txt
)
)
ECHO.
ECHO.┍┄┄┄┄┄┄┄┑
ECHO.┆ ANDROID_HOME ┆
ECHO.┕┄┄┄┄┄┄┈┙
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" |^
find /i "ANDROID_HOME" >NUL && SET noSDK=0 || SET noSDK=1
IF %noSDK%==1 (
Color 0D
ECHO. [ ERRO ] 检查ANDROID环境:未配置
ECHO. [ INFO ] 请参考指导配置环境变量
) ELSE (
ECHO. [ INFO ] 检查ANDROID环境:已配置
ECHO. -------------------------------------------------
ECHO. [ INFO ] ANDROID_HOME =
ECHO. %ANDROID_HOME%
)
ECHO.
ECHO.┍┄┄┄┄┄┄┄┑
ECHO.┆ ADB ┆
ECHO.┕┄┄┄┄┄┄┈┙
adb help 2>nul
IF %ERRORLEVEL%==9009 (
Color 0D
SET /a noAdb =1
ECHO. [ ERRO ] 检查adb环境:未配置
ECHO. [ INFO ] 请参考指导配置环境变量
) ELSE (
ECHO. [ INFO ] 检查adb环境:已配置
ECHO. -------------------------------------------------
FOR /F "delims=" %%a IN ('adb version') DO (
ECHO. [ INFO ] %%a
)
)
ECHO.
ECHO.┍┄┄┄┄┄┄┄┑
ECHO.┆ AAPT ┆
ECHO.┕┄┄┄┄┄┄┈┙
aapt v >nul
IF %ERRORLEVEL%==9009 (
Color 0D
SET /a noaapt =1
ECHO. [ INFO ] 未配置aapt环境
ECHO. [ INFO ] 请参考指导配置环境变量
) ELSE (
ECHO. [ INFO ] 检查aapt命令环境:已配置
ECHO. -------------------------------------------------
aapt v >aapt.txt
FOR /F "delims=" %%a IN (aapt.txt) DO (
ECHO. [ INFO ] %%a
del /a/f/q aapt.txt
)
)
ECHO.
ECHO.
ECHO.[按任意键关闭窗口...]
PAUSE>NUL
a.已安装配置Android环境
b.未安装配置Android环境(或部分未配置正确)
说明:初学Android者经常存在环境问题,测试新同学,折腾环境也不确定弄没弄好,定位半天,很纠结。于是写了个批处理,一方面方便,二方面节省自己时间,一看知道哪有问题。
注意:APPT不存时显示是不是内部命令,不影响脚本结果。
二、Android内存监控
@ECHO OFF
COLOR 0A
ECHO.:::::::::::::::::::::::::::::::::::::::::::::::::
ECHO.:: ::
ECHO.:: 内存(RAM)监控显示V1.0 ::
ECHO.:: ::
ECHO.:::::::::::::::::::::::::::::::::::::::::::::::::
::::::: 作者:Findyou ::
::::::: 版本:V1.0 时间:2015.03.25 ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::
SET packagename=tv.fuzegame.fuzelauncher
:: 获取得小时,格式为:24小时制,10点前补0
SET c_time_hour=%time:~0,2%
IF /i %c_time_hour% LSS 10 (
SET c_time_hour=0%time:~1,1%
)
SET logfilename="%~dp0%date:~0,4%%date:~5,2%%date:~8,2%%c_time_hour%%time:~3,2%%time:~6,2%_RAM.txt"
ECHO."内存信息监控" >%logfilename%
:Startscreencap
adb shell procrank >>%logfilename%
CLS
ECHO.:::::::::::::::::::::::::::::::::::::::::::::::::
ECHO.:: ::
ECHO.:: 内存信息监控显示 ::
ECHO.:: ::
ECHO.:::::::::::::::::::::::::::::::::::::::::::::::::
ECHO. PID Vss Rss Pss Uss cmdline
FINDSTR /C:"%packagename%" %logfilename%
ping -n 2 127.0.0.1>nul
GOTO Startscreencap 说明:内存监控命令常用几个,做APP测试时,经常需要监控内存,但不需要很强的工具时,轻量监控这个其中脚本之一
三、模拟蓝牙手柄
@ECHO OFF
Color 0A
REM ECHO.:::::::::::::::::::::::::::::::::::::::::::::::::
REM ECHO.:: ::
REM ECHO.:: 键盘模拟手柄 ::
REM ECHO.:: ::
REM ECHO.:::::::::::::::::::::::::::::::::::::::::::::::::
::::::: 作者:Findyou ::
::::::: 版本:V1.0 时间:2015.01.23 ::
::::::: 版本:V1.1 时间:2015.04.21 ::
::::::::::::::::::::::::::::::::::::::::::::::::::::::
MODE con: cols=62 lines=13
TITLE FindYou科技模拟手柄
SET keyboardcode=WSADJBNYHMV1234GQ
ECHO.
ECHO. LT (%keyboardcode:~11,1%) LB (%keyboardcode:~12,1%) RT (%keyboardcode:~13,1%) RB (%keyboardcode:~14,1%)
ECHO.
ECHO. ┍┄┄┄┄┄┄Menu (%keyboardcode:~9,1%)┄┄┄┄┄┄┄View (%keyboardcode:~10,1%)┄┄┄┄┄┄┑
ECHO. │ │
ECHO. 上 (%keyboardcode:~0,1%) Y (%keyboardcode:~7,1%)
ECHO. Start(%keyboardcode:~15,1%) X (%keyboardcode:~6,1%)
ECHO. 左 (%keyboardcode:~2,1%) 右 (%keyboardcode:~3,1%) Home (%keyboardcode:~8,1%)
ECHO. B (%keyboardcode:~5,1%)
ECHO. 下 (%keyboardcode:~1,1%) A (%keyboardcode:~4,1%)
ECHO. │ │
ECHO. ┕┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┙
:cont
choice /c %keyboardcode% /n >nul
REM ::UP
IF %errorlevel% EQU 1 ( adb shell input keyevent 19 )
REM ::DOWN
IF %errorlevel% EQU 2 ( adb shell input keyevent 20 )
REM ::LEFT
IF %errorlevel% EQU 3 ( adb shell input keyevent 21 )
REM ::RIGHT
IF %errorlevel% EQU 4 ( adb shell input keyevent 22 )
REM ::A
IF %errorlevel% EQU 5 ( adb shell input keyevent 96 )
REM ::B
IF %errorlevel% EQU 6 ( adb shell input keyevent 97 )
REM ::X
IF %errorlevel% EQU 7 ( adb shell input keyevent 99 )
REM ::Y
IF %errorlevel% EQU 8 ( adb shell input keyevent 100 )
REM ::HOME
IF %errorlevel% EQU 9 ( adb shell input keyevent 3 )
REM ::MENU
IF %errorlevel% EQU 10 ( adb shell input keyevent 109 82 )
REM ::VIEW
IF %errorlevel% EQU 11 ( adb shell input keyevent 119 )
REM ::LT
IF %errorlevel% EQU 12 ( adb shell input keyevent 104 )
REM ::LB
IF %errorlevel% EQU 13 ( adb shell input keyevent 102 )
REM ::RT
IF %errorlevel% EQU 14 ( adb shell input keyevent 105 )
REM ::RB
IF %errorlevel% EQU 15 ( adb shell input keyevent 103 )
REM ::START
IF %errorlevel% EQU 16 ( adb shell input keyevent 108 )
REM ::EXIT
IF %errorlevel% EQU 17 exit
GOTO cont说明:在最初测试终端类的盒子时,需要模拟蓝牙手柄事件,偶尔想对某一个事件进行重复操作,因此制作了这样一个小脚本,但反应慢达不到要求。后续压力测试使用Monkey速度飙升。
附:
以上脚本均为工作中原创内容,如转载还请保留出处与作者姓名Findyou,谢谢!