rsautogui aims to be a cross-platform GUI automation rust crate.

Related tags

GUI rsautogui
Overview

rsautogui

  • rsautogui aims to be a cross-platform GUI automation rust crate.
  • It lets you control the mouse and keyboard to automate interactions with other applications.
  • Currently, it's a wrapper of multiple rust crates to have pyautogui inspired syntax written in rust.

Warning Not tested on Linux and MacOS


Example Usage

Mouse

use rsautogui::{mouse, mouse::MouseButton};

fn main() {
    let pos: (u16, u16) = mouse::position(); // Returns the current mouse coordinates.

    mouse::move_to(500, 500); // Moves mouse to x, y instantly.
    mouse::move_rel(500, 500); // Moves mouse to x, y relative to its position instantly.
    mouse::drag_to(500, 500); // Drags mouse to x, y instantly.
    mouse::drag_rel(500, 500); // Drags mouse to x, y relative to its position instantly.

    mouse::click(MouseButton::Left); // Performs a mouse click with the specified button.
    mouse::down(MouseButton::Left); // Performs a mouse down with the specified button.
    mouse::up(MouseButton::Left); // Performs a mouse up with the specified button.
    mouse::scroll('x', 10); // Scrolls x or y axis n times.
}

Keyboard

use rsautogui::keyboard::{self, Key};

fn main() {
    keyboard::typewrite("lorem ipsum"); // Simulates typing the string provided.

    keyboard::key_down(Key::Layout('a')); // Presses specified key down.
    keyboard::key_up(Key::Layout('a')); // Releases specified key up.
    keyboard::key_tap(Key::Layout('a')); // Performs specified key up and down.
}

Screen

use rsautogui::screen::{self, Rgba, ImageBuffer};

fn main() {
    let size: (u16, u16) = screen::size(); // Returns the width and height of primary screen.
    let on_screen: bool = screen::on_screen(1920, 1080); // Verifies if specified x & y coordinates are present on primary screen.

    let ss: ImageBuffer<Rgba<u8>, Vec<u8>> = screen::screenshot(1920, 1080); // Returns screenshot of the primary screen.
    screen::printscreen(&ss, "./src/assets/screenshot.jpg"); // Saves the provided screenshot to a path with the specified filename and extension.

    let loc: Option<(u16, u16)> = screen::locate_pixel(screen::Rgba([255, 255, 255, 255])); // Locates the first pixel color similar to the one specified and returns its coordinate.
    let loc: Vec<(u16, u16)> = screen::locate_all_pixel(screen::Rgba([255, 255, 255, 255])); // Locates all pixel colors similar to the one specified and returns their coordinates.
    let pixel: Rgba<u8> = screen::get_pixel(500, 500); // Get the pixel color on x, y coordinate.
}

You can read more documentation of this crate in docs.rs.

You might also like...
Rust bindings to the minimalist, native, cross-platform UI toolkit `libui`
Rust bindings to the minimalist, native, cross-platform UI toolkit `libui`

Improved User Interface A cross-platform UI toolkit for Rust based on libui iui: ui-sys: iui is a simple (about 4 kLOC of Rust), small (about 800kb, i

Cross-platform native Rust menu library

A cross-platform Rust library for managing the native operating system menus.

A Rust binding of the wxWidgets cross platform toolkit.

wxRust master: / mac(0.10): This is a Rust binding for the wxWidgets cross platform toolkit. API wxRust API documentation How it works The wxRust libr

Alerion is a cross-platform Rust rewrite of Pterodactyl Wings

alerion 🛫 A complete rewrite of pterodactyl wings. Caution Here be dragons. This project is still a huge work in progress and is not ready for produc

A cross-platform Mod Manager for RimWorld intended to work with macOS, linux and Windows

TODOs are available here. Discussions, PRs and Issues are open for anyone who is willing to contribute. rrm Inspired by Spoons rmm. This is a cross-pl

An easy-to-use, 2D GUI library written entirely in Rust.

Conrod An easy-to-use, 2D GUI library written entirely in Rust. Guide What is Conrod? A Brief Summary Screenshots and Videos Feature Overview Availabl

Rust bindings for the FLTK GUI library.
Rust bindings for the FLTK GUI library.

fltk-rs Rust bindings for the FLTK Graphical User Interface library. The FLTK crate is a crossplatform lightweight gui library which can be statically

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust

Relm Asynchronous, GTK+-based, GUI library, inspired by Elm, written in Rust. This library is in beta stage: it has not been thoroughly tested and its

Clear Coat is a Rust wrapper for the IUP GUI library.

Clear Coat Clear Coat is a Rust wrapper for the IUP GUI library. IUP uses native controls and has Windows and GTK backends. A macOS backend has been o

Comments
  • Problem running the keyboard example

    Problem running the keyboard example

    Hi, I'm having an error when i try to run the example of the keyboard:

    use rsautogui::keyboard::{self, Key};
    
    fn main() {
        keyboard::typewrite("lorem ipsum"); // Simulates typing the string provided.
    
        keyboard::key_down(Key::Layout('a')); // Presses specified key down.
        keyboard::key_up(Key::Layout('a')); // Releases specified key up.
        keyboard::key_tap(Key::Layout('a')); // Performs specified key up and down.
    }
    

    I get the next error when i run cargo run .

    image

    Here it's the information about my rust, cargo and rsautogui version

    OS: Windows 10
    rustc 1.66.0 (69f9c33d7 2022-12-12)
    cargo 1.66.0 (d65d197ad 2022-11-15)
    rsautogui = "0.1.5"
    
    opened by Caresle 1
Owner
null
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

Pietro Gagliardi 10.4k Dec 31, 2022
A cross-platform GUI library for Rust, inspired by Elm

Iced A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm. Features Simple, easy-to-use, batteries-included AP

Héctor Ramón 17.5k Jan 2, 2023
Truly cross platform, truly native. multiple backend GUI for rust

WIP: Sauron-native a rust UI library that conquers all platforms ranging from desktop to mobile devices. An attempt to create a truly native, truly cr

Jovansonlee Cesar 627 Jan 5, 2023
A cross-platform GUI library for Rust focused on simplicity and type-safety

A cross-platform GUI library for Rust, inspired by Elm

Héctor Ramón 17.5k Jan 8, 2023
Cross-platform GUI toolkit written in Rust

Tuix is a cross-platform GUI toolkit written in Rust. The driving principle behind tuix is to be a self-contained, small-as-possible, but still fast,

George Atkinson 166 Dec 13, 2022
A cross-platform GUI toolkit in Rust

NXUI - Native X UI A cross-platform GUI toolkit in Rust NXUI is a GUI toolkit that calls OS native APIs as much as possible to achieve fast operation.

らて 11 Jun 3, 2022
A cross-platform GUI library for Rust, inspired by Elm

Iced A cross-platform GUI library for Rust focused on simplicity and type-safety. Inspired by Elm. Features Simple, easy-to-use, batteries-included AP

null 17.5k Dec 28, 2022
A single-header ANSI C immediate mode cross-platform GUI library

Nuklear This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed a

Immediate Mode UIs, Nuklear, etc. 6.9k Jan 8, 2023
A lightweight cross-platform system-monitoring fltk gui application based on sysinfo

Sysinfo-gui A lightweight cross-platform system-monitoring fltk gui application based on sysinfo. The UI design is inspired by stacer. The svg icons a

Mohammed Alyousef 22 Dec 31, 2022
Simple GTK Rust Fuzzer which aims to test all available classes and functions in GTK.

Gtk Rust Fuzzer Simple GTK Rust Fuzzer which aims to test all available classes and functions in GTK. It finds bugs inside GTK functions, GTK exported

Rafał Mikrut 8 Nov 19, 2022