How to emulate touch input using Tasker and root
Emulating touch input has been something that I’ve wanted the ability to do in Tasker for ages, even though I haven’t actually had a direct use for it yet. Then, a few days ago, I ran across a post on Reddit by user PinkyThePig, talking about making an app bot that uses touch emulation to work. It turns out that emulating touch with Tasker is very simple, and here’s how.
Emulating touch in Android is apparently possible with shell commands, using Tasker’s Run Shell action. The command you use is
input tap X Y
Where X and Y are coordinates. Root must be checked in the action options, and obviously Tasker needs root access to do this.
As for how you find X and Y, that’s easy: Go to system settings, developer options, and enable “Show pointer location”. Use that option to find the X and Y coordinates of whatever you need the touch emulation to press, and write them down. Then use them in the above command.
You can also emulate swipes, using the following command:
input swipe X1 Y1 X2 Y2
Where X1 Y1 are the star coordinates and X2 Y2 are the end coordinates. As an example, “input swipe 400 400 100 400” on my phone swipes the image thumbnails in a Google Play listing.
This works great on my device, but might be dependent on device and/or OS version/ROM.
This little trick has a lot of potential. You could for instance combine it with AutoVoice Continuous and make any app voice controller without even having to initiate voice input, which would be a killer thing to have in a car. You could also do like PinkyThePig and make an app bot that does something for you in an app while you’re not using the device.
EDIT: It appears this only works on Android 4.1.1 and above.