From fff6aad1c5d4035f48a56493c5068540ba77ba53 Mon Sep 17 00:00:00 2001 From: fufesou Date: Fri, 25 Nov 2022 18:30:30 +0800 Subject: [PATCH] compile win & macos Signed-off-by: fufesou --- libs/enigo/src/macos/macos_impl.rs | 16 ++++++++++++++++ libs/enigo/src/win/win_impl.rs | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/libs/enigo/src/macos/macos_impl.rs b/libs/enigo/src/macos/macos_impl.rs index fb9c2d680..937320f7d 100644 --- a/libs/enigo/src/macos/macos_impl.rs +++ b/libs/enigo/src/macos/macos_impl.rs @@ -163,6 +163,14 @@ impl Default for Enigo { } impl MouseControllable for Enigo { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn as_mut_any(&mut self) -> &mut dyn std::any::Any { + self + } + fn mouse_move_to(&mut self, x: i32, y: i32) { let pressed = Self::pressed_buttons(); @@ -319,6 +327,14 @@ impl MouseControllable for Enigo { // com/questions/1918841/how-to-convert-ascii-character-to-cgkeycode impl KeyboardControllable for Enigo { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn as_mut_any(&mut self) -> &mut dyn std::any::Any { + self + } + fn key_sequence(&mut self, sequence: &str) { // NOTE(dustin): This is a fix for issue https://github.com/enigo-rs/enigo/issues/68 // TODO(dustin): This could be improved by aggregating 20 bytes worth of graphemes at a time diff --git a/libs/enigo/src/win/win_impl.rs b/libs/enigo/src/win/win_impl.rs index e7512399e..4a4fd7fc4 100644 --- a/libs/enigo/src/win/win_impl.rs +++ b/libs/enigo/src/win/win_impl.rs @@ -105,6 +105,14 @@ fn get_error() -> String { } impl MouseControllable for Enigo { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn as_mut_any(&mut self) -> &mut dyn std::any::Any { + self + } + fn mouse_move_to(&mut self, x: i32, y: i32) { mouse_event( MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK, @@ -170,6 +178,14 @@ impl MouseControllable for Enigo { } impl KeyboardControllable for Enigo { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn as_mut_any(&mut self) -> &mut dyn std::any::Any { + self + } + fn key_sequence(&mut self, sequence: &str) { let mut buffer = [0; 2];