0

I want to create a program to auto tap continuous to screen android phone.

I tried "adb shell input tap x y" in LOOP but so slow (about 1s). I tried multiple command like: "adb shell input tap x1 y1 && adb shell input tap x2 y2" but can not resolve my problem.

How to do this action? I send an gift image for detail. my real action in phone

4
  • The command is slow because every time you have to establish adb communication, create a new shell and then execute the command. Instead open adb shell and then write and execute a sh shell script on Android side that executes input tap x y in a loop.
    – Robert
    Commented Jul 5 at 8:13
  • oh I can understand your solution. Can you tell me how to execute a command inside phone?
    – Tim Cruiz
    Commented Jul 5 at 10:46
  • juts execute adb shell and you are getting a shell on the device.
    – Robert
    Commented Jul 5 at 11:05
  • @Robert I don't know your suggestion :v can you give a topic on Stackoverflow, I tried search but not found any solution. Many thanks!
    – Tim Cruiz
    Commented Jul 5 at 11:34

1 Answer 1

0

As @Robert mentioned, running only 1 adb shell and then executing input tap in a loop will increase the rate. However you can achieve better rates avoiding executing a new input every time.

Using AndroidViewClient/culebra with CulebraTester2-public backend you will be able to obtain values like this.

#! /usr/bin/env python3

import timeit
from com.dtmilano.android.viewclient import ViewClient

helper = ViewClient.view_client_helper()
print(f"{timeit.timeit('helper.ui_device.click(500, 500)', number=1, globals=globals()):.4f}s")

giving (on a emulator):

⚠️  CulebraTester2 server should have been started and localport 9987 redirected to remote port 9987.
0.1796s

So you can run

helper.ui_device.click(x, y)

in a loop to tap very fast.

Not the answer you're looking for? Browse other questions tagged or ask your own question.