注意:
1.手機必須root
2.shell腳本需要有執行權限
流程:
1.編寫shell腳本
#!/system/bin/sh i=1 while [ $i -le 100 ] do let i++ sleep 2 input swipe 100 950 200 300 150 done
解釋:每隔2秒滑屏一次,一共滑動100次(這個腳本比較簡單,明白流程后可自行優化)
2.把shell腳本傳到/data/目錄(/system目錄也可以)
3.進入adb shell的root模式
備注:#表示root模式
4.對shell腳本授權
1.進入/data/
2.chmod 777 test.sh
5.使用后台執行shell腳本
nohup ./test.sh &
備注:
1.有的手機文件管理器不顯示system目錄,可以第三方的REguanliqi來查看系統目錄
2.運行腳本后會有一個進程id
#——————————————————下面是補充——————————————
shell中查看android進程及處理:
jobs -l................查看運行的后台進程(拔掉usb就查看不到)
ps "進程id".................篩選進程器(ps|grep "/system/bin/sh" |grep "root".............查看匹配進程)
kill -s 9 “進程id”................殺掉進程(shell腳本就不會在后台運行了)
參考教程:
https://blog.csdn.net/wdz306ling/article/details/79602739.................shell
https://blog.51cto.com/11193863/2319105..............................shell
https://blog.csdn.net/MzTestor/article/details/79206427..............Android脫離USB執行Shell腳本