Enum inputbot::MouseButton
source · pub enum MouseButton {
LeftButton,
MiddleButton,
RightButton,
X1Button,
X2Button,
OtherButton(u32),
}
Variants§
Implementations§
source§impl MouseButton
impl MouseButton
sourcepub fn bind<F: Fn() + Send + Sync + 'static>(self, callback: F)
pub fn bind<F: Fn() + Send + Sync + 'static>(self, callback: F)
Examples found in repository?
examples/autoclicker.rs (lines 10-17)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn main() {
// Bind our right mouse button to a function that autoclicks every 30 milliseconds. Hold it down
// to bake some cookies really fast!
RightButton.bind(|| {
while RightButton.is_pressed() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Bind our Caps Lock key to a function that toggles autoclicking. Go AFK and bake some
// cookies really fast without hurting your hands!
CapsLockKey.bind(move || {
while CapsLockKey.is_toggled() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Call this to start listening for bound inputs.
inputbot::handle_input_events();
}
pub fn block_bind<F: Fn() + Send + Sync + 'static>(self, callback: F)
pub fn blockable_bind<F: Fn() -> BlockInput + Send + Sync + 'static>( self, callback: F )
sourcepub fn bind_all<F: Fn(MouseButton) + Send + Sync + Clone + 'static>(callback: F)
pub fn bind_all<F: Fn(MouseButton) + Send + Sync + Clone + 'static>(callback: F)
Examples found in repository?
examples/bind_all.rs (lines 16-18)
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
// Bind all keys to a common callback event.
KeybdKey::bind_all(|event| {
match inputbot::from_keybd_key(event) {
Some(c) => println!("{c}"),
None => println!("Unregistered Key"),
};
});
// Bind all mouse buttons to a common callback event.
MouseButton::bind_all(|event| {
println!("{:?}", event);
});
// Call this to start listening for bound inputs.
inputbot::handle_input_events();
}
pub fn unbind(self)
source§impl MouseButton
impl MouseButton
sourcepub fn is_pressed(self) -> bool
pub fn is_pressed(self) -> bool
Returns true if a given MouseButton
is currently pressed (in the down position).
Examples found in repository?
examples/autoclicker.rs (line 11)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn main() {
// Bind our right mouse button to a function that autoclicks every 30 milliseconds. Hold it down
// to bake some cookies really fast!
RightButton.bind(|| {
while RightButton.is_pressed() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Bind our Caps Lock key to a function that toggles autoclicking. Go AFK and bake some
// cookies really fast without hurting your hands!
CapsLockKey.bind(move || {
while CapsLockKey.is_toggled() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Call this to start listening for bound inputs.
inputbot::handle_input_events();
}
sourcepub fn press(self)
pub fn press(self)
Presses a given MouseButton
. Note: this means the button will remain in the down
position. You must manually call release to create a full ‘click’.
Examples found in repository?
examples/autoclicker.rs (line 12)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn main() {
// Bind our right mouse button to a function that autoclicks every 30 milliseconds. Hold it down
// to bake some cookies really fast!
RightButton.bind(|| {
while RightButton.is_pressed() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Bind our Caps Lock key to a function that toggles autoclicking. Go AFK and bake some
// cookies really fast without hurting your hands!
CapsLockKey.bind(move || {
while CapsLockKey.is_toggled() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Call this to start listening for bound inputs.
inputbot::handle_input_events();
}
sourcepub fn release(self)
pub fn release(self)
Releases a given MouseButton
. This means the button would be in the up position.
Examples found in repository?
examples/autoclicker.rs (line 13)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
fn main() {
// Bind our right mouse button to a function that autoclicks every 30 milliseconds. Hold it down
// to bake some cookies really fast!
RightButton.bind(|| {
while RightButton.is_pressed() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Bind our Caps Lock key to a function that toggles autoclicking. Go AFK and bake some
// cookies really fast without hurting your hands!
CapsLockKey.bind(move || {
while CapsLockKey.is_toggled() {
LeftButton.press();
LeftButton.release();
sleep(Duration::from_millis(30));
}
});
// Call this to start listening for bound inputs.
inputbot::handle_input_events();
}
Trait Implementations§
source§impl Clone for MouseButton
impl Clone for MouseButton
source§fn clone(&self) -> MouseButton
fn clone(&self) -> MouseButton
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MouseButton
impl Debug for MouseButton
source§impl From<MouseButton> for u32
impl From<MouseButton> for u32
source§fn from(button: MouseButton) -> u32
fn from(button: MouseButton) -> u32
Converts to this type from the input type.
source§impl Hash for MouseButton
impl Hash for MouseButton
source§impl IntoEnumIterator for MouseButton
impl IntoEnumIterator for MouseButton
type Iterator = MouseButtonIter
fn iter() -> MouseButtonIter ⓘ
source§impl PartialEq<MouseButton> for MouseButton
impl PartialEq<MouseButton> for MouseButton
source§fn eq(&self, other: &MouseButton) -> bool
fn eq(&self, other: &MouseButton) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Copy for MouseButton
impl Eq for MouseButton
impl StructuralEq for MouseButton
impl StructuralPartialEq for MouseButton
Auto Trait Implementations§
impl RefUnwindSafe for MouseButton
impl Send for MouseButton
impl Sync for MouseButton
impl Unpin for MouseButton
impl UnwindSafe for MouseButton
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more