rdev
rdev copied to clipboard
Stop listen
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));
}