From eec4c02bfe92144f7db7933b756bcc635ebfed56 Mon Sep 17 00:00:00 2001 From: pentamassiv Date: Sat, 18 Nov 2023 15:43:37 +0100 Subject: [PATCH 1/3] xdo: Use more types directly from the std library --- src/linux/xdo.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/linux/xdo.rs b/src/linux/xdo.rs index e54e0135..a3133148 100644 --- a/src/linux/xdo.rs +++ b/src/linux/xdo.rs @@ -1,6 +1,9 @@ -use std::{ffi::CString, ptr}; +use std::{ + ffi::{c_char, c_int, c_ulong, c_void, CString}, + ptr, +}; -use libc::{c_char, c_int, c_ulong, c_void, useconds_t}; +use libc::useconds_t; use log::debug; From ef53d6d637856b6622ef2caad8fff9fbf12df96f Mon Sep 17 00:00:00 2001 From: pentamassiv Date: Sat, 18 Nov 2023 16:03:05 +0100 Subject: [PATCH 2/3] Linux: Got rid of some unwraps --- src/linux/wayland.rs | 2 +- src/macos/macos_impl.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/linux/wayland.rs b/src/linux/wayland.rs index 06e02d47..dec777e7 100644 --- a/src/linux/wayland.rs +++ b/src/linux/wayland.rs @@ -190,7 +190,7 @@ impl Con { fn get_time(&self) -> u32 { let duration = self.base_time.elapsed(); let time = duration.as_millis(); - time.try_into().unwrap() + time.try_into().unwrap_or(u32::MAX) } /// Press/Release a keycode diff --git a/src/macos/macos_impl.rs b/src/macos/macos_impl.rs index 077d5716..493c0fdf 100644 --- a/src/macos/macos_impl.rs +++ b/src/macos/macos_impl.rs @@ -456,9 +456,7 @@ impl Enigo { #[must_use] #[allow(clippy::missing_panics_doc)] // It never panics pub fn delay(&self) -> u32 { - // Unwrapping here is okay, be cause we always initially have a u32 that gets - // converted to an u64. The reverse is always possible - self.delay.try_into().unwrap() + self.delay.try_into().unwrap_or(u32::MAX) } /// Set the delay per keypress in milliseconds From 0d24224ddbe626663fd8f35abf5613b0df2e3700 Mon Sep 17 00:00:00 2001 From: pentamassiv Date: Sat, 18 Nov 2023 15:26:30 +0100 Subject: [PATCH 3/3] Bump version no to 0.2.0-rc1 --- Cargo.toml | 14 ++++++++++---- README.md | 12 +++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 72074b5e..5a922cf0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,25 @@ [package] name = "enigo" -version = "0.1.3" +version = "0.2.0-rc1" authors = [ "pentamassiv ", "Dustin Bensing ", ] edition = "2021" rust-version = "1.65" -description = "Cross-platform (Linux, Windows & macOS) library to simulate keyboard and/or mouse events" +description = "Cross-platform (Linux, Windows & macOS) library to simulate keyboard and mouse events" documentation = "https://docs.rs/enigo/" homepage = "https://github.com/enigo-rs/enigo" repository = "https://github.com/enigo-rs/enigo" readme = "README.md" -keywords = ["input", "mouse", "testing", "keyboard", "automation"] -categories = ["development-tools::testing", "api-bindings", "hardware-support"] +keywords = ["simulate", "input", "mouse", "keyboard", "automation"] +categories = [ + "development-tools::testing", + "api-bindings", + "hardware-support", + "os", + "simulation", +] license = "MIT" exclude = [".github", "examples", ".gitignore", "rustfmt.toml"] diff --git a/README.md b/README.md index 596efc77..4cf078bd 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ ![Rust version](https://img.shields.io/badge/rust--version-1.65+-brightgreen.svg) [![Crates.io](https://img.shields.io/crates/v/enigo.svg)](https://crates.io/crates/enigo) -[![Discord chat](https://img.shields.io/discord/315925376486342657.svg)](https://discord.gg/Eb8CsnN) -[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/enigo-rs/Lobby) # enigo @@ -19,17 +17,17 @@ Cross platform input simulation in Rust! - [x] MacOS text - [x] Win mouse - [x] Win text -- [x] Custom Parser +- [x] Serialize/Deserialize ```Rust let mut enigo = Enigo::new(&Settings::default()).unwrap(); -enigo.mouse_move_to(500, 200); -enigo.mouse_click(Button::Left); -enigo.key_sequence_parse("{+CTRL}a{-CTRL}{+SHIFT}Hello World{-SHIFT}"); +enigo.move_mouse(500, 200, Abs).unwrap(); +enigo.button(Button::Left, Click).unwrap(); +enigo.text("Hello World! here is a lot of text ❤️").unwrap(); ``` -For more look at examples +For more look at the examples. ## Runtime dependencies