#![deny(clippy::pedantic)]
#![allow(clippy::cast_lossless)]
#![allow(clippy::cast_possible_truncation)]
#![allow(clippy::cast_possible_wrap)]
#![allow(clippy::cast_sign_loss)]
#![allow(deprecated)]
#[cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
#[cfg(target_os = "windows")]
mod win;
#[cfg(target_os = "windows")]
pub use crate::win::Enigo;
#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
pub use crate::macos::Enigo;
#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
pub use crate::linux::Enigo;
pub mod dsl;
#[cfg(feature = "with_serde")]
#[macro_use]
extern crate serde_derive;
#[cfg(feature = "with_serde")]
extern crate serde;
#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum MouseButton {
Left,
Middle,
Right,
ScrollUp,
ScrollDown,
ScrollLeft,
ScrollRight,
}
pub trait MouseControllable {
fn mouse_move_to(&mut self, x: i32, y: i32);
fn mouse_move_relative(&mut self, x: i32, y: i32);
fn mouse_down(&mut self, button: MouseButton);
fn mouse_up(&mut self, button: MouseButton);
fn mouse_click(&mut self, button: MouseButton);
fn mouse_scroll_x(&mut self, length: i32);
fn mouse_scroll_y(&mut self, length: i32);
#[must_use]
fn main_display_size(&self) -> (i32, i32);
#[must_use]
fn mouse_location(&self) -> (i32, i32);
}
#[cfg_attr(feature = "with_serde", derive(Serialize, Deserialize))]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum Key {
Alt,
Backspace,
CapsLock,
#[deprecated(since = "0.0.12", note = "now renamed to Meta")]
Command,
Control,
Delete,
DownArrow,
End,
Escape,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
F16,
F17,
F18,
F19,
F20,
Home,
LeftArrow,
Meta,
Option,
PageDown,
PageUp,
Return,
RightArrow,
Shift,
Space,
#[deprecated(since = "0.0.12", note = "now renamed to Meta")]
Super,
Tab,
UpArrow,
#[deprecated(since = "0.0.12", note = "now renamed to Meta")]
Windows,
Layout(char),
Raw(u16),
}
pub trait KeyboardControllable {
fn key_sequence_parse(&mut self, sequence: &str)
where
Self: Sized,
{
self.key_sequence_parse_try(sequence)
.expect("Could not parse sequence");
}
fn key_sequence_parse_try(&mut self, sequence: &str) -> Result<(), dsl::ParseError>
where
Self: Sized,
{
dsl::eval(self, sequence)
}
fn key_sequence(&mut self, sequence: &str);
fn key_down(&mut self, key: Key);
fn key_up(&mut self, key: Key);
fn key_click(&mut self, key: Key);
}
impl Enigo {
#[must_use]
pub fn new() -> Self {
Self::default()
}
}
use std::fmt;
impl fmt::Debug for Enigo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "Enigo")
}
}