如何为 Android 中的任何应用程序模拟触摸?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25495234/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to simulate touch for any application in Android?
提问by jeff
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.
所以我想要实现的应该是一系列输入(触摸:{x1,y1}、{x2,y2} 等)并控制任何应用程序(例如 Facebook),就像真正的用户正在触摸该坐标一样。
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.
编辑:我想该解决方案(如果存在)可能会涉及 PC。要么将我的真实 Android 设备连接到我的 PC,要么使用虚拟 Android 设备。但是,虚拟设备不支持 Google Play,我需要使用 Google Play 的一些应用程序。
回答by Anand Varkey Philips
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 : FREPAndroid App from Play Store(Link).
无需生根:如果您想重复一系列步骤,例如填写表格,重复游戏步骤,因为重做很无聊,您可以尝试:Play Store 中的FREPAndroid 应用程序(链接)。
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 Droidfrom Play Store.
如果您想添加条件场景,例如,当您使用家庭 Wifi 玩《部落冲突》时,自动打开数据并禁用 wifi(因为印度的 Airtel Wifi 是不可预测的,可以让您失去部落War!!)使用Play 中的Macro Droid店铺。
You can try these as well: MahiroMany apps are available based on Taskerlike, Auto Input. You can maybe code/write macro to make personal solution with this Tasker App.
您也可以尝试这些: Mahiro许多基于Tasker 的应用程序都可用,例如Auto Input。您可以使用此 Tasker 应用程序编写代码/编写宏来制作个人解决方案。
回答by mbmc
You can also try Robotium(where you programmatically, in Java, click buttons etc), or MonkeyRunner(to send random UI events).
您还可以尝试Robotium(以编程方式使用 Java,单击按钮等)或MonkeyRunner(发送随机 UI 事件)。
回答by user3818494
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.
您可以使用robotium 进行编程(在java 中)以单击屏幕上的任何按钮或任何坐标。它的设置和使用都很简单。
回答by Zanval
Have you tried Selendroid? http://selendroid.io/
你试过 Selendroid 吗? http://selendroid.io/
I haven't tried it myself, I only know of it because I use Selenium for Web Applications.
我自己没有尝试过,我只知道它是因为我将 Selenium 用于 Web 应用程序。
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).
Selenium 能够模拟一系列输入事件。为此,您可以使用坐标或 DOM 元素(div、按钮、文本字段等)。
Your usecase should be exactly what selendroid was made for.
您的用例应该正是 selendroid 的用途。