0

Hey here is my code for swipe on adb.

adb shell input swipe 200 1600 1000 1600 1000
sleep 2

But I want to loop it and run continuously. I'm calling my .sh files on terminal like this:

sh ./auto_swipe.sh

This runs the script only 1 time. How can I run it continuously?

themmfa
  • 499
  • 4
  • 15

1 Answers1

2

Possibly write a loop in script as shown here

max=6
for i in `seq 2 $max`
do
adb shell input swipe 200 1600 1000 1600 1000
sleep 2
done

To generate random number between 800,1600 script is ,

X=800
Y=1600
RANGE=$((Y-X+1))
R=$(($(($RANDOM%$RANGE))+X))
echo "$R"

inspired from this article

Manohar
  • 22,116
  • 9
  • 108
  • 144
  • Thanks this works like a charm. Also, is there a way to randomize the x and y locations for more complex swipe actions? I mean I want to randomy swipe from y=800,1600 ? @Manohar – themmfa Feb 25 '22 at 06:38
  • 1
    @sonelektrikci added code for generating random number – Manohar Feb 25 '22 at 06:46