#/bin/bash
device=`adb wait-for-devices`
echo device
adb root
adb shell <<EOF
#home 键
input keyevent 3
#验证启动应用是否成功
function startApp() {
result=`dumpsys window | grep 'mCurrentFocus'`
if [[ $result =~ $1 ]]
then
echo -e "\033[7;32m start \$1 success \033[0m"
else
echo -e "\033[4;31m start \$1 failed \033[0m"
fi
}
#点击configuration
input tap 883 612
sleep 1
startApp SystemLanguageActivity
#上滑列表
input swipe 864 501 864 300
sleep 1
exit
EOF
echo -e "\033[41;36m run finish \033[0m"
echo -e "\033[41;36m Press enter to exit \033[0m"
read
#下面是解说
1. input tap 883 612 点击某个坐标
2.sleep 2 睡眠2s
3.input swipe 864 501 864 300 从坐标864 501 上滑到 864 300
4.input keyevent 3 方控硬按键 home,回到首页
5.startApp()方法来获取当前页面的包名,调用 startApp xx, 只要包名包含xx控制台就会打印出success,否则fail
6.demo.sh 直接双击脚本可以运行