这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@qzd1989
Copy link

@qzd1989 qzd1989 commented Jul 2, 2024

Supported on macos and windows, I'm a newbie of Rust, so please check it carefully.

use std::{
    thread::{self, spawn},
    time::Duration,
};

use rdev::{listen, stop_listen};

fn main() {
    spawn(|| {
        println!("start");
        if let Err(error) = listen(|event| {
            println!("My callback {:?}", event);
        }) {
            println!("Error: {:?}", error)
        }
        println!("end");
    });
    thread::sleep(Duration::from_secs(5));
    spawn(|| {
        stop_listen();
    });
    thread::sleep(Duration::from_secs(3600));
}

@qzd1989 qzd1989 closed this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant