#mouse-input #keyboard #mouse #hotkey #api-bindings

hookmap-core

Global hooks and input simulation fo keyboard and mouse

15 releases

0.2.1 Dec 6, 2022
0.2.0 May 13, 2022
0.1.12 Jan 2, 2022
0.1.11 Oct 7, 2021
0.1.1 Jul 31, 2021

#1998 in Hardware support


Used in hookmap

MIT/Apache

44KB
1K SLoC

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);
            }
        }
    }
}

Dependencies

~1–39MB
~563K SLoC