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

panicked at 'cannot transmute_copy if U is larger than T' #121

Closed
NaokiM03 opened this issue Aug 30, 2022 · 5 comments
Closed

panicked at 'cannot transmute_copy if U is larger than T' #121

NaokiM03 opened this issue Aug 30, 2022 · 5 comments

Comments

@NaokiM03
Copy link
Contributor

NaokiM03 commented Aug 30, 2022

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.
rust-lang/rust#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
@psi-cmd
Copy link

psi-cmd commented Sep 6, 2022

Thanks, I just ran into the problem and your solution saved my time.

@mrchantey
Copy link

My steps:

  1. Get the PR
git clone https://github.com/enigo-rs/enigo.git
gh pr checkout 122
  1. Update Cargo.toml
[dependencies]
enigo = {path = "path/to/enigo", version = "0.0.14"}

@NaokiM03
Copy link
Contributor Author

This issue is closed because the pull request has been merged.

@NPCDW
Copy link

NPCDW commented Feb 28, 2023

Please when will a new version be released on crates.io

@pentamassiv
Copy link
Collaborator

The new version was released :)

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

5 participants