Can adb be used to simulate 3 long taps on a device?

I am trying to simulate 3 (simultaneous non-sequential) long taps on an Android device using adb.

The most promising guide I found was here , but I could not change it to use it.

Any thoughts on how to accomplish such a feat?

Thanks.

+5
source share
2 answers

I found a very simple job to simulate long strokes. Simulate wipes at the same point.

input swipe <x1> <y1> <x2> <y2> [duration in milliseconds] 

Where x1 == x2 and y1 == y2.

This will simulate a swipe, but since your start point and end point are the same, it will act as if it were pressed lng.

+6
source

I also worked on something related to this; and after loads of research, this is the best I have - it can do exactly what you want, but there are several drawbacks depending on your context.

It's simple, just send low-level input events like:

simulating touch down event

 sendevent /dev/input/event4 1 330 1 // touch down sendevent /dev/input/event4 0 0 0 // end of report 

Waiting after a touch event as if the user's finger is still on the device (i.e. long press)

Sensory Release Event Modeling

 sendevent /dev/input/event4 1 330 0 // touch release sendevent /dev/input/event4 0 0 0 // end of report 

SYNTAX

 sendevent <device> <type> <code> <value> 

For a better documentation on arguments, refer to https://android.googlesource.com/platform/external/kernel-headers/+/8bc979c0f7b0b30b579b38712a091e7d2037c77e/original/uapi/linux/input.h

PROS:

  • I found that using the sendevent command instead of the input command is much faster, most likely because you can send events of interest to you at a certain level.
  • You have great control over the device, for example, the touch screen, keyboard, buttons, thermometer, etc.

MINUSES:

  • You will need to determine which device you are interested in manually. In my example, I used / dev / input / event 4, but I don't rely on the same thing on your device. Devices differ from phone to phone, so you probably need to use the getevent command and then manually determine which device is your touch screen. This can be a real pain, especially if you are trying to programmatically identify the touch device for any Android phone, simply because even the name of the device can technically differ from phone to phone.

Note

If you are looking for an easier way to send a tap, you can use the command

 input tap <x> <y> 

but be careful, you have no way to determine how long to simulate a click (i.e., a long press is not possible)

Good luck.

+3
source

All Articles