使用可访问性服务在屏幕上查找按钮或文本的坐标
是否可以使用可访问性服务来查找按钮或屏幕上的文本的坐标,然后在该按钮或文本字段上模拟点击,但不要触摸字段,就像您需要触摸Android Talkback中的字段一样阅读?
例如,是否可以使用这样的可访问性服务:
将活动的意图发送到可访问性服务,并提供一些用于不同任务的附加功能。
在接收特定额外字符串的意图时,该服务将打开开发人员选项。
无需触摸文本“运行服务”,可访问性服务应在开发人员选项中找到该文本字段(或按钮)坐标并模拟点击。
是否可以在Android上?
Is it possible to use the accessibility service to find the coordinates of a button or the text on the screen, then simulate tapping on that button or text field, but without touching the field, like you need to touch the field in Android TalkBack to hear reading?
For example, is it possible to use the accessibility service like this:
Send the intent from the activity to the accessibility service with some extras for different tasks.
When receiving an intent with a certain extra string, the service will open the developer options.
Without touching the text "Running services", the accessibility service should find that text field (or button) coordinates in the developer options and simulate a tap on it.
Is that possible on Android or not?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
tl; dr;我想我已经写了服务您可能会发现有趣的
需要牢记的一些要点:
recyclerview
s的问题是view> View> Viewholder
是作为用户滚动的不同元素重复使用。但是,您可以在可访问性服务中执行此操作:
id标准:
注意两者:
要单击一个元素:
如果您真的很热衷于获取节点的屏幕坐标,则可以随时使用 getBoundsinscreen 方法,但随后您必须完成所有的数学和工作,这比需要的要困难。 ,但是我在bash 做
adb uiautomator时做到了dump
和解析XML,剥离我想要的节点的界限,只要使用uiautomator dump
禁用可访问性服务。TL;DR; I think I've written a service you might find interesting
Some points to keep in mind:
RecyclerView
s as theViewHolder
is reused for different elements as the user scrolls.However you can do this in an accessibility service:
When searching by id criteria:
When searching by text criteria:
Note for both:
To click on an element:
If you are really passionate about getting the screen coordinates of a node you can always use the getBoundsInScreen method, but then you have to do all the math and stuff and that's harder than it needs to be. But I did it in bash when doing a
adb uiautomator dump
and parsing the XML, stripping the bounds for the node I want, just be wary that usinguiautomator dump
disables the accessibility service.