Auto.js - Android Automation in Javascript

Discuss other useful utilities, general computing tips & tricks, Internet resources, etc.
william_ahk
Posts: 496
Joined: 03 Dec 2018, 20:02

Auto.js - Android Automation in Javascript

14 Jan 2024, 23:21

logo.png
logo.png (11 KiB) Viewed 971 times

Auto.js is definitely the closest alternative to AutoHotkey on Android. You can write Javascript to automate the UI, and even creating UIs. Best part is that it doesn't require root permission. I've used it quite intensively and it is an absolute gem. They don't even have a documentation in English so I guess that's why it's so unpopular. Also the original author no longer maintains the open source version, but there are forks in active development like AutoX.js, which I currently use.

Here's a translation of the introduction:
The sections of this document are roughly divided into modules, which can be broadly categorized as "Automated Operations" modules (control operations, touch simulation, key simulation, etc.) and other modules (device, application, interface, etc.).

The "Automated Operations" section can be further divided into two main types: control-based operations and coordinate-based operations.

Coordinate-based operations involve specifying specific screen coordinates for actions such as clicking, for example, click(100, 200). This method is more feasible in game scripts and can achieve good compatibility when combined with features like image recognition, color detection, and coordinate scaling. However, this approach is not very efficient for general software scripts and requires Android 7.0 or higher or root permissions to execute.

For software scripts (e.g., batch adding contacts, automatically extracting SMS verification codes, etc.), we recommend using control-based simulated operations, combined with notifications, key events, etc., to achieve better workflow.

The other modules mainly include:
app: Application. Launching applications, uninstalling applications, using applications to view and edit files, access web pages, send inter-app broadcasts, etc.
console: Console. Recording runtime logs, errors, information, etc.
device: Device. Obtaining device screen dimensions, system version information, controlling device volume, brightness, etc.
engines: Script engines. Used to launch other scripts.
events: Events and listeners. Key listeners, notification listeners, touch listeners, etc.
floaty: Floaty. Used to display custom floating windows.
files: File system. File creation, information retrieval, read/write operations.
http: HTTP. Sending HTTP requests, such as GET, POST, etc.
websocket: Websocket client and server. Allows for active message pushing.
images, colors: Image and color processing. Screenshotting, image cropping, image recognition, reading and saving images, etc.
keys: Key simulation. For example, simulating volume keys, Home key, etc.
shell: Shell commands.
threads: Multithreading support.
ui: UI interface. Used to display custom UI interfaces and interact with users.

To get a feel of what it's like, below is an example script that clears all the notifications when 🔉 is pressed.

Code: Select all

events.observeKey();
events.onKeyDown("volume_down", function(event){
    notifications();
    sleep(500);
    click("Clear all");
});

Return to “Other Utilities & Resources”

Who is online

Users browsing this forum: No registered users and 20 guests