Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
win_binder
A simple library to listen and send events globally for keyboard and mouse on Windows.
Inspired by rdev, but built with windows-rs instead of winapi-rs.
Listening to Global Events
use ;
// This will block.
if let Err = listen
Sending Events
use ;
use ;
send;
send;
send;
send;
send;
send;
send;
Main Structs
Event
Event represents the event data that is received. It contains the name of the key or action as interpreted by the OS.
In order to detect what a user types, we need to plug to the OS level management
of keyboard state (modifiers like shift, CTRL, but also dead keys if they exist).
EventType corresponds to a physical event, corresponding to QWERTY layout
Event represents the event data that is received. It contains the name of the key
or action as interpreted by the OS and it will respect the layout.
/// When events arrive from the system we can add some information
/// time is when the event was received.
Be careful, Event::name, might be None, but also String::from(""), and might contain not displayable Unicode characters. We send exactly what the OS sends us, so do some sanity checking before using it.
EventType
In order to manage different OS, the current EventType choices is a mix and match to account for all possible events. There is a safe mechanism to detect events no matter what, which are the Unknown() variant of the enum which will contain some OS specific value. Also, not that not all keys are mapped to an OS code, so simulate might fail if you try to send an unmapped key. Sending Unknown() variants will always work (the OS might still reject it).
/// In order to manage different OS, the current EventType choices is a mix&match
/// to account for all possible events.
Getting the Main Screen Size
use ;
let = display_size.unwrap;
assert!;
assert!;
Keyboard state
We can define a dummy Keyboard, that we will use to detect
what kind of EventType trigger some String. We get the currently used
layout for now !
Caveat : This is layout dependent. If your app needs to support
layout switching, don't use this!
Caveat: Only shift and dead keys are implemented, Alt+Unicode code on Windows won't work.
use ;
let mut keyboard = new.unwrap;
let string = keyboard.add;
// string == Some("s")
Grabbing Global Events. (Requires unstable_grab Feature)
Installing this library with the unstable_grab feature adds the grab function
which hooks into the global input device event stream.
By supplying this function with a callback, you can intercept
all keyboard and mouse events before they are delivered to applications / window managers.
In the callback, returning None ignores the event and returning the event lets it pass.
There is no modification of the event possible here (yet).
Note: the use of the word unstable here refers specifically to the fact that the grab API is unstable and subject to change
use ;
let callback = ;
// This will block.
if let Err = grab
Serialization
Event data returned by the listen and grab functions can be serialized and deserialized with
Serde if you install this library with the serialize feature.