16 unstable releases (3 breaking)

Uses old Rust 2015

0.4.0 Jan 17, 2020
0.3.1 Nov 13, 2019
0.3.0 Oct 23, 2019
0.2.1 Jul 12, 2019
0.1.4 Jun 3, 2018

#311 in Unix APIs

Download history 96/week @ 2023-11-25 99/week @ 2023-12-02 99/week @ 2023-12-09 94/week @ 2023-12-16 180/week @ 2023-12-23 125/week @ 2023-12-30 155/week @ 2024-01-06 143/week @ 2024-01-13 136/week @ 2024-01-20 110/week @ 2024-01-27 96/week @ 2024-02-03 122/week @ 2024-02-10 161/week @ 2024-02-17 169/week @ 2024-02-24 177/week @ 2024-03-02 74/week @ 2024-03-09

597 downloads per month
Used in mcfly

MIT/Apache

325KB
2K SLoC

Docs Crates.io Travis Build Status Appveyor Build Status

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

The following will move the mouse across the screen as a sine wave:

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 mut 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));
    }
}

This will enter the keys from the string "Hello, world!" and then prompt an alert with the same text:

extern crate autopilot;

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

License

This project is licensed under either the Apache-2.0 or MIT license, at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~14MB
~96K SLoC