Skip to main content

Crate autoitx

Crate autoitx 

Source
Expand description

AutoItX’s API, in Rust, on Windows and macOS.

autoitx drives other applications’ user interfaces: keystrokes, mouse, clipboard, windows, processes. The API is modeled on AutoItX, the DLL interface to AutoIt v3, so existing AutoIt automation ports over almost mechanically — but unlike AutoItX, it also runs natively on macOS.

§Platform support

BackendHow
WindowsFFI into AutoItX3_x64.dll, loaded at runtime
macOSNative — Accessibility API, CGEvent, NSPasteboard
LinuxPlanned

Capabilities are split three ways:

  • The portable core compiles everywhere.
  • ext::windows and ext::macos hold what only one platform can do. Calling a Windows-only function in a macOS build is a compile error, not a runtime surprise. (Only the module matching the target platform exists in any given build, which is why these are not direct links — browse docs.rs to see both.)
  • recipes expresses portable intent whose mechanism differs per platform — “wait until the app stops being busy” is one operation, even though Windows polls the cursor shape and macOS probes the Accessibility message timeout.

§Three things this fixes about hand-written AutoIt code

Keystroke injection. Send interprets {}!+^#, so interpolating user or database data straight into a send string lets that data execute as key commands. Here, Keys::text escapes by default and the raw form has to be asked for by name.

Reading the screen through the clipboard. The common idiom — put a sentinel on the clipboard, copy, then check whether it changed — races with anything else touching the clipboard. recipes::read_screen_text waits on the OS clipboard sequence number instead, which cannot race.

Racing several outcomes with no timeout. AutoIt waits on one window at a time, so “the form closed, or an error appeared, or a block notice did” gets written as a hand-rolled polling loop that reliably forgets to give up. AutoIt::wait_for_any takes the timeout as a parameter and reports which outcome happened.

AutoIt and AutoItX are products of AutoIt Consulting Ltd. This project is not affiliated with, endorsed by, or sponsored by them, and the AutoItX3 DLL is not distributed with this crate. See NOTICE for details on obtaining it.

Re-exports§

pub use autoit::AutoIt;docsrs or macOS or Windows or mock-loader
pub use autoit::AutoItBuilder;docsrs or macOS or Windows or mock-loader
pub use autoit::MouseButton;docsrs or macOS or Windows or mock-loader
pub use autoit::Session;docsrs or macOS or Windows or mock-loader
pub use autoit::WinCondition;docsrs or macOS or Windows or mock-loader
pub use control::Control;docsrs or Windows or mock-loader
pub use error::Error;
pub use error::Result;
pub use geometry::PixelCoordSpace;
pub use geometry::Point;
pub use geometry::Rect;
pub use geometry::Size;
pub use keys::Keys;
pub use options::KeyMap;
pub use options::Options;
pub use options::ShowState;
pub use options::Speed;
pub use options::TitleMatchMode;
pub use options::WinState;
pub use selector::Selector;

Modules§

autoitdocsrs or macOS or Windows or mock-loader
The automation handle.
controldocsrs or Windows or mock-loader
Naming a control inside a window.
error
What can go wrong.
ext
Platform-specific capabilities.
geometry
Coordinates, in one space, on every platform.
keys
Keystroke sequences, in AutoIt’s Send language.
options
AutoIt’s option table, and the defaults automation silently depends on.
recipesdocsrs or macOS or Windows or mock-loader
Portable intent, platform-specific mechanism.
selector
Naming a window.

Macros§

keys
Builds a Keys from a string literal, validated at compile time.