Fix lock_screen and ctrl_alt_del

This commit is contained in:
Asura 2022-07-18 07:38:05 -07:00
parent a2d8c31e85
commit a8e4591217
3 changed files with 5 additions and 10 deletions

View File

@ -21,7 +21,7 @@ appveyor = { repository = "pythoneer/enigo-85xiy" }
[dependencies]
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
log = "0.4.17"
log = "0.4"
rdev = { git = "https://github.com/asur4s/rdev" }
[features]

View File

@ -103,7 +103,6 @@ impl Enigo {
self.tx.send((PyMsg::Char('\0'), true)).ok();
}
#[inline]
fn send_pynput(&mut self, key: &Key, is_press: bool) -> bool {
if unsafe { PYNPUT_EXIT || !PYNPUT_REDAY } {
@ -112,14 +111,8 @@ impl Enigo {
if let Key::Layout(c) = key {
return self.tx.send((PyMsg::Char(*c), is_press)).is_ok();
}
if let Key::Raw(chr) = key {
fn string_to_static_str(s: String) -> &'static str {
Box::leak(s.into_boxed_str())
}
return self
.tx
.send((PyMsg::Str(string_to_static_str(chr.to_string())), is_press))
.is_ok();
if let Key::Raw(_) = key {
return false;
}
#[allow(deprecated)]
let s = match key {

View File

@ -450,6 +450,7 @@ pub fn lock_screen() {
key_event.down = true;
key_event.set_chr('l' as _);
key_event.modifiers.push(ControlKey::Meta.into());
key_event.mode = 3;
handle_key(&key_event);
key_event.down = false;
handle_key(&key_event);
@ -462,6 +463,7 @@ pub fn lock_screen() {
key_event.set_chr('q' as _);
key_event.modifiers.push(ControlKey::Meta.into());
key_event.modifiers.push(ControlKey::Control.into());
key_event.mode = 3;
handle_key(&key_event);
key_event.down = false;
handle_key(&key_event);