How to simulate touch for any application in Android?
Asked Answered
M

5

23

I know some similar questions have already been asked, but I think they are asking for simulating touch in their own applications, however I want to make an agent that can "use" any application.

So what I want to achieve should take as a series of inputs (touch: {x1,y1}, {x2,y2}, etc) and control any application (such as Facebook) just as if a genuine user is touching that coordinate.

Is there any example, or a way for this? Or an already existing question about this?

Thanks for any help!

Edit: I imagine that the solution -if any exists- will probably involve a PC. either connecting my real Android device to my PC, or using a Virtual Android Device. However, virtual devices do not support Google Play, and I need to use some apps from Google Play.

Metabolism answered 25/8, 2014 at 22:21 Comment(5)
It's impossible to inject touch events from your app to others and that's a good security feature IMO.Oliverolivera
@user3249477 you are right :) But I want to believe that there are some "hacky" solutions.Metabolism
How does this app do it without root : Airplane Mode - play.google.com/store/apps/…Trabeated
You can check my answer in the bottom!Oldline
@Oliverolivera -- it's definitely not impossible -- there are apps that do it!Adumbral
O
9

I had to search a bit for this. I was also looking for this solution.

NO ROOTING REQUIRED FOR THIS: If you want to repeat a sequence of steps like fill a form, repeat game steps because redoing is boring, You can try : FREP Android App from Play Store(Link).

If you want to add conditional scenarios like, when you play Clash of Clans with home Wifi, turn data automatically and disable wifi ( Because Airtel Wifi in India is unpredictable and can make you loose the clan war!!) use, Macro Droid from Play Store.

You can try these as well: Mahiro Many apps are available based on Tasker like, Auto Input. You can maybe code/write macro to make personal solution with this Tasker App.

Oldline answered 18/12, 2017 at 10:56 Comment(1)
Thanks to your answer, I used frep in conjunction with bluestacks and tapo, to resume the status of my camerasDeina
C
4

You can also try Robotium (where you programmatically, in Java, click buttons etc), or MonkeyRunner (to send random UI events).

Cotta answered 25/8, 2014 at 22:43 Comment(0)
T
1

Have you tried Selendroid? http://selendroid.io/

I haven't tried it myself, I only know of it because I use Selenium for Web Applications.

Selenium is able to simulate a series of input events. For this purpose, one can either work with coordinates or DOM elements (divs, buttons, textfields etc).

Your usecase should be exactly what selendroid was made for.

Tigges answered 25/8, 2014 at 22:34 Comment(3)
Thanks! +1. But in the "getting started" section, it says that you should have the .apk file. Do Play apps have apk files ? Edit: my real aim is to make a bot for a game, so there are no DOM elements I guess, I just need to simulate touch and swipe gesture with manually supplied coordinates.Metabolism
@CengizFrostclaw you can search through xda-developers. For example, they have many versions of the gmail .apk (forum.xda-developers.com/sitesearch.php?q=gmail%20apk) edit: I have tried out manual coordinates on a webapplication with selenium, it works just as good as DOM element selection.Tigges
Just found an interesting post on xda for you. You can extract .apk files via ADB. (forum.xda-developers.com/showthread.php?t=1755436)Tigges
S
0

You can use robotium to program (in java) to click on any button or on any co-ordinates on the screen. Its simple to set up and use.

Sita answered 28/8, 2014 at 21:22 Comment(0)
C
0

If you have the developer mode on your device enabled, you can run:

adb shell input tap x y

adb shell input help  # to read more options/help

Take also a good look at this QA in Android: https://android.stackexchange.com/questions/115320/is-it-possible-to-simulate-touch-without-root

Contractual answered 26/7, 2023 at 19:48 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.