Home > Software design >  Send complex swipes to Android with Adb/Python (no sendevent)
Send complex swipes to Android with Adb/Python (no sendevent)

Time:10-13

I'm trying to automate some applications on my android phone and I need to swipe from point A (140, 950) to point B (140, 1200) and then to point C (400, 1200) without releasing.

And I already tried input swipe

adb shell "input touchscreen swipe 126 459 413 472 & input touchscreen swipe 413 472 407 769" but this results in 2 swipes being executed at the same time, not continuously.

Sendevent requires root access

enter image description here

CodePudding user response:

I've found the solution I was looking for!

With motionevent from adb input you can have more control over the touchscreen.

 adb shell motionevent <DOWN|UP|MOVE|CANCEL> <x> <y>

So with python to move from point A to B and then to C:

device.shell(f"motionevent DOWN {aX} {aY}")
device.shell(f"motionevent MOVE {bX} {bY}")
device.shell(f"motionevent UP {cX} {cY}")
  • Related