enigo
enigo copied to clipboard
panicked at 'cannot transmute_copy if U is larger than T'
Describe the bug
On windows, functions that use fn keybd_event(flags: u32, vk: u16, scan: u16)
internally cause panic when used in Rust 1.64.0 or later.
See also the following issue. https://github.com/rust-lang/rust/issues/100545
thread 'main' panicked at 'cannot transmute_copy if U is larger than T', /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634\library\core\src\mem\mod.rs:1057:5
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library\std\src\panicking.rs:584
1: core::panicking::panic_fmt
at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634/library\core\src\panicking.rs:142
2: core::mem::transmute_copy<winapi::um::winuser::KEYBDINPUT,winapi::um::winuser::INPUT_u>
at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634\library\core\src\mem\mod.rs:1057
3: enigo::win::win_impl::keybd_event
at .\src\win\win_impl.rs:36
4: enigo::win::win_impl::impl$1::key_down
at .\src\win\win_impl.rs:138
5: key::main
at .\examples\key.rs:9
6: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
at /rustc/f6f9d5e73d5524b6281c10a5c89b7db35c330634\library\core\src\ops\function.rs:248
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\examples\key.exe` (exit code: 101)
To Reproduce
Use rustc 1.64.0-nightly and run cargo run --example key.
Expected behavior
Expects a
input, but in fact panic occurs.
Environment (please complete the following information):
- OS: Windows
- Rust: rustc 1.64.0-nightly (f6f9d5e73 2022-08-04)
- Library Version: enigo 0.0.14
Thanks, I just ran into the problem and your solution saved my time.
My steps:
- Get the PR
git clone https://github.com/enigo-rs/enigo.git
gh pr checkout 122
- Update Cargo.toml
[dependencies]
enigo = {path = "path/to/enigo", version = "0.0.14"}
This issue is closed because the pull request has been merged.
Please when will a new version be released on crates.io
The new version was released :)