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.


use enigo::*;
let mut enigo = Enigo::new();
use enigo::*;
let mut enigo = Enigo::new();
enigo.mouse_move_to(500, 200);
enigo.mouse_move_relative(100, 100);
enigo.key_sequence("hello world");



The main struct for handling the event emitting



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


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.



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


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