enigo: Sending keyboard input doesn't work
Describe the bug Sending keyboard input doesn’t work.
To Reproduce
I took the given example code and ran it with cargo run
.
main.rs
:
use enigo::{Enigo, MouseControllable, KeyboardControllable, MouseButton};
fn main() {
let mut enigo = Enigo::new();
enigo.mouse_move_to(500, 200);
enigo.mouse_click(MouseButton::Left);
enigo.key_sequence_parse("{+CTRL}a{-CTRL}{+SHIFT}Hello World{-SHIFT}");
}
Cargo.toml
:
[package]
name = "test"
version = "0.1.0"
edition = "2021"
[dependencies]
enigo = "0.0.14"
Expected behavior
I expected that the mouse was clicked at position (500, 200) and then the text HELLO WORLD
was written.
Actual behavior The mouse position is correctly changed and the mouse is clicked. But no text was written, instead I get the following output in the terminal:
PS C:\Personal\Path\Test> cargo run
Compiling test v0.1.0 (C:\Personal\Path\Test)
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running `target\debug\test.exe`
thread 'main' panicked at 'cannot transmute_copy if U is larger than T', /rustc/897e37553bba8b42751c67658967889d11ecd120\library\core\src\mem\mod.rs:1057:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\test.exe` (exit code: 101)
Environment
- OS: Windows 11
- Rust: rustc 1.65.0 (897e37553 2022-11-02)
- Library Version: enigo 0.0.14
Additional context I also tried:
key_click
key_down
key_sequence
with no luck.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 16 (1 by maintainers)
The new version was released 😃
Fixed in https://github.com/enigo-rs/enigo/pull/150 😃
Seems like it is the same issue as this one here: https://github.com/enigo-rs/enigo/issues/99 There already is a PR (https://github.com/enigo-rs/enigo/pull/100), but it is outdated and cannot be merged. I’ll update the PR and merge it soon.
@pentamassiv, that’s completely fair. No pressure. I’m just adding more information as I get them.
I guess we should add that functionality.
Right now we are still trying to improve the CI tests and get the PRs merged. We just started updating the crate a few weeks ago so we are not yet up to speed. In a few weeks we should be able to fix this error too.