Simulate char in win

This commit is contained in:
chiehw 2023-03-24 21:51:56 +08:00 committed by asur4s
parent 799685f0cd
commit dbe1516096

View File

@ -1233,16 +1233,23 @@ fn translate_keyboard_mode(evt: &KeyEvent) {
// remote: Shift + 1 => 1 // remote: Shift + 1 => 1
let mut en = ENIGO.lock().unwrap(); let mut en = ENIGO.lock().unwrap();
#[cfg(target_os = "linux")] #[cfg(target_os = "macos")]
en.key_sequence(seq);
#[cfg(any(target_os = "linux", target_os = "windows"))]
{ {
simulate_(&EventType::KeyRelease(RdevKey::ShiftLeft)); if get_modifier_state(Key::Shift, &mut en) {
simulate_(&EventType::KeyRelease(RdevKey::ShiftRight)); simulate_(&EventType::KeyRelease(RdevKey::ShiftLeft));
}
if get_modifier_state(Key::RightShift, &mut en) {
simulate_(&EventType::KeyRelease(RdevKey::ShiftRight));
}
for chr in seq.chars() { for chr in seq.chars() {
#[cfg(target_os = "windows")]
rdev::simulate_char(chr).ok();
#[cfg(target_os = "linux")]
en.key_click(Key::Layout(chr)); en.key_click(Key::Layout(chr));
} }
} }
#[cfg(not(target_os = "linux"))]
en.key_sequence(seq);
} }
Some(key_event::Union::Chr(..)) => { Some(key_event::Union::Chr(..)) => {
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]