这是indexloc提供的服务,不要输入任何密码
Skip to content

key_click triggers a segmentation fault when called with Key::Layout argument #124

@isharedx

Description

@isharedx

Describe the bug
A segmentation fault is triggered when calling key_click function with a argument of type Key::Layout on MacOS.

To Reproduce

use enigo::{Enigo, Key, KeyboardControllable};
use std::thread;
use std::time::Duration;

fn main() {
    thread::sleep(Duration::from_secs(2));
    let mut enigo = Enigo::new();

    println!("1");
    enigo.key_down(Key::Meta);
    println!("2");
    enigo.key_click(enigo::Key::Layout('c'));
    println!("3");
    enigo.key_up(Key::Meta);
    println!("4");
}

Run with command cargo run, and will get an output as the following:

❯ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target/debug/enigo-debug`
1
2
zsh: segmentation fault  cargo run

Expected behavior
No crash, and send a key_click event.

Environment (please complete the following information):

  • OS: macOS Ventura 13.0.1 (22A400)
  • Rust: rustc 1.64.0 (a55dd71d5 2022-09-19)
  • Library Version: enigo 0.0.13

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions