Struct mouse_keyboard_input::VirtualDevice
source · pub struct VirtualDevice {
pub sender: ChannelSender,
/* private fields */
}
Fields§
§sender: ChannelSender
Implementations§
source§impl VirtualDevice
impl VirtualDevice
sourcepub fn default() -> Result<Self>
pub fn default() -> Result<Self>
Examples found in repository?
More examples
examples/mouse.rs (line 7)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let mut device = VirtualDevice::default().unwrap();
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll down by 100
device.scroll_y(-100).unwrap();
// move cursor 50 pixels up and 50 pixels to the right from the current position
device.move_mouse(50, 50).unwrap();
//click the left mouse button
device.click(BTN_LEFT).unwrap();
}
}
pub fn new(writing_interval: Duration, channel_size: usize) -> Result<Self>
pub fn send_to_channel( kind: u16, code: u16, value: i32, sender: &ChannelSender ) -> EmptyResult
pub fn send_press(button: Button, sender: &ChannelSender) -> EmptyResult
pub fn send_release(button: Button, sender: &ChannelSender) -> EmptyResult
sourcepub fn send_click(button: Button, sender: &ChannelSender) -> EmptyResult
pub fn send_click(button: Button, sender: &ChannelSender) -> EmptyResult
Examples found in repository?
examples/channels.rs (line 16)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
thread::spawn(move || {
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll vertically by 100
VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
// move cursor vertically from the current position by 50
VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
//click the left mouse button
VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
};
})
}
pub fn send_mouse_move_x(x: Coord, sender: &ChannelSender) -> EmptyResult
pub fn send_mouse_move_y(y: Coord, sender: &ChannelSender) -> EmptyResult
sourcepub fn send_mouse_move(
x: Coord,
y: Coord,
sender: &ChannelSender
) -> EmptyResult
pub fn send_mouse_move( x: Coord, y: Coord, sender: &ChannelSender ) -> EmptyResult
Examples found in repository?
examples/channels.rs (line 14)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
thread::spawn(move || {
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll vertically by 100
VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
// move cursor vertically from the current position by 50
VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
//click the left mouse button
VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
};
})
}
pub fn send_scroll_x(value: Coord, sender: &ChannelSender) -> EmptyResult
sourcepub fn send_scroll_y(value: Coord, sender: &ChannelSender) -> EmptyResult
pub fn send_scroll_y(value: Coord, sender: &ChannelSender) -> EmptyResult
Examples found in repository?
examples/channels.rs (line 12)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
thread::spawn(move || {
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll vertically by 100
VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
// move cursor vertically from the current position by 50
VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
//click the left mouse button
VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
};
})
}
sourcepub fn flush_channel_every_interval(self) -> JoinHandle<()>
pub fn flush_channel_every_interval(self) -> JoinHandle<()>
pub fn synchronize(&mut self) -> EmptyResult
pub fn move_mouse_raw_x(&mut self, x: Coord) -> EmptyResult
pub fn move_mouse_raw_y(&mut self, y: Coord) -> EmptyResult
pub fn move_mouse_raw(&mut self, x: Coord, y: Coord) -> EmptyResult
pub fn move_mouse_x(&mut self, x: Coord) -> EmptyResult
pub fn move_mouse_y(&mut self, y: Coord) -> EmptyResult
sourcepub fn move_mouse(&mut self, x: Coord, y: Coord) -> EmptyResult
pub fn move_mouse(&mut self, x: Coord, y: Coord) -> EmptyResult
Examples found in repository?
examples/mouse.rs (line 15)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let mut device = VirtualDevice::default().unwrap();
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll down by 100
device.scroll_y(-100).unwrap();
// move cursor 50 pixels up and 50 pixels to the right from the current position
device.move_mouse(50, 50).unwrap();
//click the left mouse button
device.click(BTN_LEFT).unwrap();
}
}
pub fn scroll_raw_x(&mut self, value: Coord) -> EmptyResult
pub fn scroll_raw_y(&mut self, value: Coord) -> EmptyResult
pub fn scroll_x(&mut self, value: Coord) -> EmptyResult
sourcepub fn scroll_y(&mut self, value: Coord) -> EmptyResult
pub fn scroll_y(&mut self, value: Coord) -> EmptyResult
Examples found in repository?
examples/mouse.rs (line 13)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let mut device = VirtualDevice::default().unwrap();
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll down by 100
device.scroll_y(-100).unwrap();
// move cursor 50 pixels up and 50 pixels to the right from the current position
device.move_mouse(50, 50).unwrap();
//click the left mouse button
device.click(BTN_LEFT).unwrap();
}
}
pub fn press(&mut self, button: Button) -> EmptyResult
pub fn release(&mut self, button: Button) -> EmptyResult
sourcepub fn click(&mut self, button: Button) -> EmptyResult
pub fn click(&mut self, button: Button) -> EmptyResult
Examples found in repository?
More examples
examples/mouse.rs (line 17)
6 7 8 9 10 11 12 13 14 15 16 17 18 19
fn main() {
let mut device = VirtualDevice::default().unwrap();
for _ in 1..5 {
thread::sleep(Duration::from_secs(1));
// scroll down by 100
device.scroll_y(-100).unwrap();
// move cursor 50 pixels up and 50 pixels to the right from the current position
device.move_mouse(50, 50).unwrap();
//click the left mouse button
device.click(BTN_LEFT).unwrap();
}
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for VirtualDevice
impl RefUnwindSafe for VirtualDevice
impl Send for VirtualDevice
impl Sync for VirtualDevice
impl Unpin for VirtualDevice
impl UnwindSafe for VirtualDevice
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