Crates.io | hookmap-core |
lib.rs | hookmap-core |
version | 0.2.1 |
source | src |
created_at | 2021-07-31 17:10:17.234836 |
updated_at | 2022-12-06 08:59:23.019245 |
description | Global hooks and input simulation fo keyboard and mouse. |
homepage | |
repository | https://github.com/keke1008/hookmap |
max_upload_size | |
id | 429767 |
size | 46,995 |
A core library of hookmap
This library provides input simulation and global hooks for keyboard and mouse.
use hookmap_core::{button::Button, event::Event, mouse};
fn main() {
let rx = hookmap_core::install_hook();
while let Ok((event, native_handler)) = rx.recv() {
match event {
Event::Button(event) => {
native_handler.dispatch();
match event.target {
Button::RightArrow => println!("Left"),
Button::UpArrow => println!("Up"),
Button::LeftArrow => println!("Right"),
Button::DownArrow => println!("Down"),
_ => {}
};
}
Event::Cursor(e) => {
native_handler.block();
// Reverses mouse cursor movement
let (dx, dy) = e.delta;
mouse::move_relative(-dx, -dy);
}
Event::Wheel(e) => {
native_handler.dispatch();
println!("delta: {}", e.delta);
}
}
}
}