{"id":22663379,"url":"https://github.com/efjerryyang/uiohook-rs","last_synced_at":"2025-04-12T07:22:28.604Z","repository":{"id":252349440,"uuid":"840168623","full_name":"efJerryYang/uiohook-rs","owner":"efJerryYang","description":"uiohook-rs is a Rust wrapper for the libuiohook, providing cross-platform keyboard and mouse hooking","archived":false,"fork":false,"pushed_at":"2025-02-15T07:04:39.000Z","size":111,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T02:52:33.341Z","etag":null,"topics":["hook","keyboard","libuiohook","mouse","uiohook","wheel"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/efJerryYang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-09T05:45:50.000Z","updated_at":"2025-04-10T03:35:41.000Z","dependencies_parsed_at":"2024-08-09T07:30:06.191Z","dependency_job_id":"84c85241-13c3-48c6-afd0-f84c6945f94f","html_url":"https://github.com/efJerryYang/uiohook-rs","commit_stats":null,"previous_names":["efjerryyang/uiohook-rs"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efJerryYang%2Fuiohook-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efJerryYang%2Fuiohook-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efJerryYang%2Fuiohook-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/efJerryYang%2Fuiohook-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/efJerryYang","download_url":"https://codeload.github.com/efJerryYang/uiohook-rs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248531130,"owners_count":21119704,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hook","keyboard","libuiohook","mouse","uiohook","wheel"],"created_at":"2024-12-09T12:18:45.131Z","updated_at":"2025-04-12T07:22:28.597Z","avatar_url":"https://github.com/efJerryYang.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# uiohook-rs\n\n[![Crates.io](https://img.shields.io/crates/v/uiohook-rs.svg)](https://crates.io/crates/uiohook-rs)\n\n`uiohook-rs` is a Rust wrapper for the [libuiohook](https://github.com/kwhat/libuiohook), providing cross-platform keyboard and mouse hooking capabilities.\n\n## Features\n\n- Cross-platform support (Linux, macOS, Windows)\n- Low-level keyboard and mouse event handling\n- Easy-to-use Rust API\n\n**Note**: All examples have now been tested on macOS, Windows and Linux.  \nOn macOS the examples have been updated to use the `CoreFoundation` run loop (`CFRunLoop`) for proper event dispatch and exit.\n\n## Usage\n\nHere's a basic example of how to use `uiohook-rs`:\n\n```rust\nuse uiohook_rs::{EventHandler, Uiohook, UiohookEvent};\n\nstruct MyEventHandler;\n\nimpl EventHandler for MyEventHandler {\n    fn handle_event(\u0026self, event: \u0026UiohookEvent) {\n        println!(\"Event: {:?}\", event);\n    }\n}\n\nfn main() {\n    let event_handler = MyEventHandler;\n    let uiohook = Uiohook::new(event_handler);\n\n    if let Err(e) = uiohook.run() {\n        eprintln!(\"Error: {}\", e);\n    }\n    \n    // Stop the hook\n    if let Err(e) = uiohook.stop() {\n        eprintln!(\"Error: {}\", e);\n    }\n}\n```\n\n## Running the Demo\n\nThere are several example programs available under the `examples/` directory, including demos for general event handling (`demo.rs`), pretty-printed output (`pretty_demo.rs`), and specific handlers for keyboard, mouse, and wheel events. Except for the `pretty_demo.rs`, all other examples use the minimal code to demonstrate the hook functionality.\n\nTo run the demo:\n\n1. Clone the repo:\n\n   ```sh\n   git clone https://github.com/efJerryYang/uiohook-rs.git\n   cd uiohook-rs\n   ```\n\n2. Run the demo:\n\n   ```sh\n   cargo run --example demo\n   ```\n\n3. Press Ctrl-C to exit. See the output:\n\n    ```txt\n    Press Ctrl-C to exit\n    MOVED    | Mouse             | X: 802   | Y: 644   | Button: 0    | Clicks: 0   \n    PRESSED  | Caps Lock         | Code: 58    | Raw: 65509\n    RELEASED | Caps Lock         | Code: 58    | Raw: 65509\n    PRESSED  | Caps Lock         | Code: 58    | Raw: 65509\n    RELEASED | Caps Lock         | Code: 58    | Raw: 65509\n    PRESSED  | Left Shift        | Code: 42    | Raw: 65505\n    PRESSED  | B                 | Code: 48    | Raw: 66   \n    TYPED    | B                 | Code: 66    | Raw: 66   \n    RELEASED | B                 | Code: 48    | Raw: 66   \n    RELEASED | Left Shift        | Code: 42    | Raw: 65505\n    PRESSED  | H                 | Code: 35    | Raw: 104  \n    TYPED    | h                 | Code: 104   | Raw: 104  \n    RELEASED | H                 | Code: 35    | Raw: 104  \n    PRESSED  | Mouse             | X: 802   | Y: 644   | Button: 1    | Clicks: 1   \n    RELEASED | Mouse             | X: 802   | Y: 644   | Button: 1    | Clicks: 1   \n    CLICKED  | Mouse             | X: 802   | Y: 644   | Button: 1    | Clicks: 1   \n    PRESSED  | Mouse             | X: 802   | Y: 644   | Button: 1    | Clicks: 1   \n    DRAGGED  | Mouse             | X: 803   | Y: 644   | Button: 0    | Clicks: 1   \n    ... (more DRAGGED events)\n    DRAGGED  | Mouse             | X: 920   | Y: 630   | Button: 0    | Clicks: 0   \n    DRAGGED  | Mouse             | X: 921   | Y: 630   | Button: 0    | Clicks: 0   \n    RELEASED | Mouse             | X: 921   | Y: 630   | Button: 1    | Clicks: 0   \n    PRESSED  | Left Control      | Code: 29    | Raw: 65507\n    PRESSED  | C                 | Code: 46    | Raw: 99   \n    TYPED    | c                 | Code: 99    | Raw: 99   \n    Exiting...\n    ```\n\n## License\n\nGNU General Public License v3.0, see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefjerryyang%2Fuiohook-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fefjerryyang%2Fuiohook-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fefjerryyang%2Fuiohook-rs/lists"}