#cross-platform #gui #automation

autopilot

A simple, cross-platform GUI automation library for Rust

7 releases

0.1.6 Sep 6, 2018
0.1.5 Sep 2, 2018
0.1.4 Jun 3, 2018
0.1.3 May 27, 2018
0.1.1 Apr 30, 2018

#14 in macOS APIs

Download history 28/week @ 2018-06-14 40/week @ 2018-06-21 53/week @ 2018-06-28 44/week @ 2018-07-05 34/week @ 2018-07-12 40/week @ 2018-07-19 28/week @ 2018-07-26 48/week @ 2018-08-02 76/week @ 2018-08-09 43/week @ 2018-08-16 36/week @ 2018-08-23 40/week @ 2018-08-30 50/week @ 2018-09-06

186 downloads per month

Apache-2.0

320KB
2K SLoC

Docs Crates.io

AutoPilot

AutoPilot is a Rust port of the Python C extension AutoPy, a simple, cross-platform GUI automation library for Python. For more information, see the README on that repo.

Currently supported on macOS, Windows, and X11 with the XTest extension.

Examples

extern crate autopilot;
extern crate rand;
use rand::Rng;

const TWO_PI: f64 = std::f64::consts::PI * 2.0;
fn sine_mouse_wave() {
    let screen_size = autopilot::screen::size();
    let scoped_height = screen_size.height / 2.0 - 10.0; // Stay in screen bounds.
    let rng = rand::thread_rng();
    for x in 0..screen_size.width as u64 {
        let y = (scoped_height * ((TWO_PI * x as f64) / screen_size.width).sin() + 
                 scoped_height).round();
        let duration: u64 = rng.gen_range(1, 3);
        autopilot::mouse::move_to(autopilot::geometry::Point::new(
            x as f64,
            y as f64
        )).expect("Unable to move mouse");
        std::thread::sleep(std::time::Duration::from_millis(duration));
    }
}
extern crate autopilot;

fn main() {
    autopilot::key::type_string("Hello, world!", None, None, &[]);
    let _ = autopilot::alert::alert("Hello, world!", None, None, None);
}

Dependencies

~3MB
~59K SLoC