#!/usr/bin/bash
#这是微信运动自动点击程序
#原理就是利用adb获取布局,来模拟点击小红心
exit_game()
{
echo "等待5秒后退出应用"
sleep 5
exit 0
}
RST="$(tput sgr0)"
RED="${RST}$(tput setaf 1)"
BRED="${RST}$(tput bold)$(tput setaf 1)"
GREEN="${RST}$(tput setaf 2)"
YELLOW="${RST}$(tput setaf 3)"
BYELLOW="${RST}$(tput bold)$(tput setaf 3)"
BLUE="${RST}$(tput setaf 4)"
CYAN="${RST}$(tput setaf 6)"
BCYAN="${RST}$(tput bold)$(tput setaf 6)"
ICYAN="${RST}$(tput sitm)$(tput setaf 6)"
clear
runadb=$(adb connect localhost:5555 2>&1)
#echo runadb: ${runadb} \n\n
error_info="error:"
refused_info="refused"
if_contains_error_info=$(echo ${runadb} | grep "${error_info}")
if_contains_refused_info=$(echo ${runadb} | grep "${refused_info}")
if [[ "$if_contains_error_info" != "" ]] || [[ "$if_contains_refused_info" != "" ]]
then
echo ${RED}\本机未开启网络调试模式,请按下面步骤进行开启:${RST}
echo
echo ${GREEN}\步骤1,将手机设置成为usb调试模式${RST}
echo ${GREEN}\方法:百度关键字\"安卓手机系统怎样打开USB调试模式\"${RST}
echo ${GREEN}\进入关于手机-\>点击版本号7次,即可打开开发者选项${RST}
echo ${GREEN}\进入开发者选项 打开usb 调试 华为机型还应打开“仅充电”模式下充许adb调试${RST}
echo
echo ${GREEN}\步骤2,连接电脑后运行 adb tcpip 5555${RST}
echo ${GREEN}\提示 \"restarting in TCP mode port: 5555\" 就表明已经开启网络调试模式${RST}
echo
echo ${BLUE}\到重启手机之前,都可以正常使用本程序 ${RST}
echo ${BLUE}\在正常使用中,最小化微信后即可停止本程序 ${RST}
exit_game
fi
#启动微信界面
adb -s localhost:5555 shell am start com.tencent.mm/.ui.LauncherUI >/dev/null 2>&1
sleep 2
#当前界面是否是微信运动排行榜
is_wechat_activity=0
itouched=0
#检查当前界面是否是微信运动排行榜
check_is_wechat_sport()
{
currentActivity=$(adb -s localhost:5555 shell dumpsys activity | grep ActivityRecord |head -n 1)
key="plugin.exdevice.ui.ExdeviceRankInfoUI"
if [[ $currentActivity == *$key* ]]
then
#echo is wechat
is_wechat_activity=1
else
is_wechat_activity=0
fi
}
#检查当前界面是否是微信运动排行榜
pull_wechat_sport()
{
check_is_wechat_sport
if [[ is_wechat_activity -eq 1 ]]
then
echo ${GREEN}\当前窗口为\"微信运动-\>步数排行榜\"${RST}
#获取当前界面的ui.xml
adb -s localhost:5555 shell uiautomator dump /sdcard/ui.xml >/dev/null 2>&1
adb -s localhost:5555 pull /sdcard/ui.xml >/dev/null 2>&1
fi
}
readXmlandClick()
{
click_first=1
#echo "The number of parameters is: ${#}"
for p in "$@"
do
#echo currenp is ${p}
if [[ "$p" -eq 0 ]] ; then
click_first=0
#echo "detect first"
fi
done
array_x=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
array_y=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
array_index=0
#sed -n -e 's/c5s/c5s\n\n/g' -e 's/\/><\/node><\/node><\/node><\/node>/\n\n&/gp' ui.xml | while read line
OUTFILE=`sed -n -e 's/c5s/c5s\n\n/g' -e 's/\/><\/node><\/node><\/node><\/node>/\n\n&/gp' ui.xml`
wh
2021,shell脚本手机微信8.0,微信运动,自动点赞小伙伴的一些总结
最新推荐文章于 2023-10-27 15:29:42 发布