Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In MacOS, enigo.text doesn't insert text correctly when holding the Command or Control key #297

Open
xitanggg opened this issue Jun 23, 2024 · 0 comments

Comments

@xitanggg
Copy link

Describe the bug
Thanks for creating this helpful library. I observe a bug in MacOS, where enigo.text doesn't insert text correctly if user is holding the Command or Control key

To Reproduce
Below is a simple code snip to insert Hello world! after 3 seconds

let mut enigo = Enigo::new(&Settings::default()).unwrap();
thread::sleep(time::Duration::from_millis(3000));
enigo.text("Hello world!").unwrap();

Expected behavior
Happy path: Run the script, observe Hello world! is printed correctly.
Non-happy path: Run the script, hold Command (or Control) key, observe Hello world! isn't printed.

Environment (please complete the following information):

  • OS: macOS
  • Rust: rustc 1.79.0
  • Library Version: latest

Additional context
I was able to figure out a workaround to this issue, which is to release the key before calling enigo.text

let mut enigo = Enigo::new(&Settings::default()).unwrap();
thread::sleep(time::Duration::from_millis(3000));
enigo.key(Key::Meta, Release).unwrap();
enigo.text("Hello world!").unwrap();

This bug affects application built on top of enigo that uses global keyboard shortcut containing Command / Control to trigger text, in which case text insert would fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant