Getting started
Widget-based automation means selecting widgets on the screen, reading their information, or performing actions on them. For most apps, this approach is highly compatible across devices. For games, however, the UI is usually not built from standard widgets, so the methods and APIs in this section typically won’t work. For game scripts, see Automation - coordinate-based actions.
Widget-based automation relies on the Accessibility service. It is recommended to call auto() at the start of your script to ensure Accessibility is enabled. If the script reaches a statement that requires Accessibility while it is not enabled, it will throw an exception and navigate to the Accessibility settings screen. This is a poor UX because the user must rerun the script. In later versions, a “wait until Accessibility is enabled and then continue” function will be added.
You can also put "auto"; at the beginning of a script to indicate that it requires Accessibility. This is not recommended because the marker must be at the absolute start (no comments/whitespace/other statements before it). Prefer auto() to ensure Accessibility is enabled.
