obv-mikhail / InputBot

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

How to define some multi-keys hotkeys? #102

Open Mikachu2333 opened 6 months ago

Mikachu2333 commented 6 months ago

Sry for bother, as a roob in rust, I couldn't create some multi-keys hotkeys with your project. Here is my code.

I'd want to create Ctrl+Alt+S and Ctrl+Alt+W hotkeys and run my command and meet trouble for no response.

fn reg_hotkeys(exe_path: PathBuf) {
    println!("Start Hotkey.");
    LControlKey.bind(move || {
        println!("LControl");
        let exe_path = exe_path.clone();
        while LAltKey.is_pressed() {
            println!("LControl+LAlt");
            while SKey.is_pressed() {
                println!("LControl+LAlt+S");
                let _ = Command::new(exe_path.clone()).spawn().unwrap();
            }
            while WKey.is_pressed() {
                println!("LControl+LAlt+W");
                let _ = Command::new(exe_path.clone())
                    .arg("--pin:clipboard")
                    .spawn()
                    .unwrap();
            }
        }
    });
}
Mikachu2333 commented 6 months ago

May similar to

47 #10