Crate enigo [] [src]

Enigo lets you simulate mouse and keyboard input-events as if they were made by the actual hardware. The goal is to make it available on different operating systems like Linux, macOS and Windows – possibly many more but Redox and *BSD are planned. Please see the Repo for the current status.

I consider this library in an early alpha status, the API will change in in the future. The keyboard handling is far from being very usable. I plan to build a simple DSL that will resemble something like:

"hello {+SHIFT}world{-SHIFT} and break line{ENTER}"

The current status is that you can just print unicode characters like emoji without the {+SHIFT} DSL or any other "special" key on the Linux, macOS and Windows operating system.

Possible use cases could be for testing user interfaces on different plattforms, building remote control applications or just automating tasks for user interfaces unaccessible by a public API or scripting laguage.

For the keyboard there are currently two modes you can use. The first mode is represented by the key_sequence function its purpose is to simply write unicode characters. This is independent of the keyboardlayout. Please note that you're not be able to use modifier keys like Control to influence the outcome. If you want to use modifier keys to e.g. copy/paste use the Layout variant. Please note that this is indeed layout dependent.

Examples

use enigo::*;
let mut enigo = Enigo::new();
//paste
enigo.key_down(Key::Control);
enigo.key_click(Key::Layout('v'));
enigo.key_up(Key::Control);
use enigo::*;
let mut enigo = Enigo::new();
enigo.mouse_move_to(500, 200);
enigo.mouse_down(MouseButton::Left);
enigo.mouse_move_relative(100, 100);
enigo.mouse_up(MouseButton::Left);
enigo.key_sequence("hello world");

Structs

Enigo

The main struct for handling the event emitting

Enums

Key

Keys to be used TODO(dustin): make real documentation

MouseButton

MouseButton represents a mouse button, and is used in for example mouse_click. WARNING: Types with the prefix Scroll IS NOT intended to be used, and may not work on all operating systems.

Traits

KeyboardControllable

Representing an interface and a set of keyboard functions every operating system implementation should implement.

MouseControllable

Representing an interface and a set of mouse functions every operating system implementation should implement.