hookmap-core

Crates.iohookmap-core
lib.rshookmap-core
version0.2.1
sourcesrc
created_at2021-07-31 17:10:17.234836
updated_at2022-12-06 08:59:23.019245
descriptionGlobal hooks and input simulation fo keyboard and mouse.
homepage
repositoryhttps://github.com/keke1008/hookmap
max_upload_size
id429767
size46,995
(keke1008)

documentation

https://docs.rs/hookmap-core

README

hookmap-core

Crates.io API reference

A core library of hookmap

This library provides input simulation and global hooks for keyboard and mouse.

Supported OS

  • Windows 10

Eample

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);
            }
        }
    }
}
Commit count: 496

cargo fmt