From b526bf4a67f7e05b2d3f739864ecc31cabc18a85 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Sun, 8 May 2022 18:12:02 +0800 Subject: [PATCH] work around of italian keyboard shift+"." issue https://github.com/rustdesk/rustdesk/issues/366#issuecomment-1120379312 --- libs/enigo/examples/key.rs | 7 ++++--- libs/enigo/src/win/win_impl.rs | 7 ++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/libs/enigo/examples/key.rs b/libs/enigo/examples/key.rs index 472f377b9..5887634a0 100644 --- a/libs/enigo/examples/key.rs +++ b/libs/enigo/examples/key.rs @@ -6,7 +6,8 @@ fn main() { thread::sleep(Duration::from_secs(2)); let mut enigo = Enigo::new(); - enigo.key_down(Key::Layout('a')).ok(); - thread::sleep(Duration::from_secs(1)); - enigo.key_up(Key::Layout('a')); + enigo.key_down(Key::Shift).ok(); + enigo.key_down(Key::Layout('.')).ok(); + enigo.key_up(Key::Layout('.')); + enigo.key_up(Key::Shift); } diff --git a/libs/enigo/src/win/win_impl.rs b/libs/enigo/src/win/win_impl.rs index 4a5f9f807..79a7c0b49 100644 --- a/libs/enigo/src/win/win_impl.rs +++ b/libs/enigo/src/win/win_impl.rs @@ -370,7 +370,12 @@ impl Enigo { unsafe { GetWindowThreadProcessId(GetForegroundWindow(), std::ptr::null_mut()) }; unsafe { LAYOUT = GetKeyboardLayout(current_window_thread_id) }; let keycode_and_shiftstate = unsafe { VkKeyScanExW(chr as _, LAYOUT) }; - keycode_and_shiftstate as _ + if keycode_and_shiftstate == (EVK_DECIMAL as i16) && chr == '.' { + // a workaround of italian keyboard shift + '.' issue + unsafe { VkKeyScanW(chr as _) as _ } + } else { + keycode_and_shiftstate as _ + } } else { 0 }