obv-mikhail / InputBot

Rust library for creating global hotkeys, and simulating inputs
MIT License
421 stars 74 forks source link

I just wanted to make a macro but I'm getting this error in runtime: ... #74

Closed RixCasti closed 1 year ago

RixCasti commented 1 year ago

Error: thread '' panicked at 'cannot transmute_copy if Dst is larger than Src', /rustc/69f9c33d71c871fc16ac445211281c6e7a340943\library\core\src\mem\mod.rs:1056:5

I'm using the latest version (0.5.1) I was testing with the mouse and the error doesn't exists, but it always happens when I use the keyboard.

Code:

use inputbot::{
    handle_input_events,
    KeybdKey::{Numpad1Key, XKey},
};
use std::{thread::sleep, time::Duration};

fn main() {
    Numpad1Key.bind(|| {
        while Numpad1Key.is_pressed() {
            XKey.press();
            sleep(Duration::from_millis(17));
            XKey.release();
        }
    });

    handle_input_events();
}
rscarson commented 1 year ago

Same issue after updating rust here.

rscarson commented 1 year ago

It does appear to have been fixed in master, when will a new crate be published with those changes?

In the meantime, using inputbot = { git = "https://github.com/obv-mikhail/InputBot" } in cargo.toml is a workaround