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)
6fn main() {
7 let mut device = VirtualDevice::default().unwrap();
8
9 for _ in 1..3 {
10 thread::sleep(Duration::from_secs(1));
11
12 // gradually scroll down by 100
13 device.smooth_scroll(0, -100).unwrap();
14 // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15 device.smooth_move_mouse(250, 250).unwrap();
16 //click the left mouse button
17 device.click(BTN_RIGHT).unwrap();
18 }
19
20 for _ in 1..2 {
21 thread::sleep(Duration::from_secs(1));
22
23 // scroll down by 100
24 device.scroll_y(-100).unwrap();
25 // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26 device.move_mouse(250, 250).unwrap();
27 //click the left mouse button
28 device.click(BTN_RIGHT).unwrap();
29 }
30}
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)
6fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
7 thread::spawn(move || {
8 for _ in 1..5 {
9 thread::sleep(Duration::from_secs(1));
10
11 // scroll vertically by 100
12 VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
13 // move cursor vertically from the current position by 50
14 VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
15 //click the left mouse button
16 VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
17 };
18 })
19}
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)
6fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
7 thread::spawn(move || {
8 for _ in 1..5 {
9 thread::sleep(Duration::from_secs(1));
10
11 // scroll vertically by 100
12 VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
13 // move cursor vertically from the current position by 50
14 VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
15 //click the left mouse button
16 VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
17 };
18 })
19}
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)
6fn write_events_in_thread(sender: ChannelSender) -> JoinHandle<()> {
7 thread::spawn(move || {
8 for _ in 1..5 {
9 thread::sleep(Duration::from_secs(1));
10
11 // scroll vertically by 100
12 VirtualDevice::send_scroll_y(100, &sender.clone()).unwrap();
13 // move cursor vertically from the current position by 50
14 VirtualDevice::send_mouse_move(50, 50, &sender.clone()).unwrap();
15 //click the left mouse button
16 VirtualDevice::send_click(BTN_LEFT, &sender.clone()).unwrap();
17 };
18 })
19}
Sourcepub fn flush_channel_every_interval(self) -> JoinHandle<()>
pub fn flush_channel_every_interval(self) -> JoinHandle<()>
pub fn write_batch(&mut self, batch: &[EventParams]) -> EmptyResult
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 buffered_move_mouse_x(&mut self, x: Coord) -> Vec<EventParams> ⓘ
pub fn buffered_move_mouse_y(&mut self, y: Coord) -> Vec<EventParams> ⓘ
pub fn buffered_move_mouse(&mut self, x: Coord, y: Coord) -> Vec<EventParams> ⓘ
pub fn gradual_move_mouse_raw(&mut self, x: Coord, y: Coord) -> Result<()>
Sourcepub fn smooth_move_mouse(&mut self, x: Coord, y: Coord) -> Result<()>
pub fn smooth_move_mouse(&mut self, x: Coord, y: Coord) -> Result<()>
Examples found in repository?
examples/mouse.rs (line 15)
6fn main() {
7 let mut device = VirtualDevice::default().unwrap();
8
9 for _ in 1..3 {
10 thread::sleep(Duration::from_secs(1));
11
12 // gradually scroll down by 100
13 device.smooth_scroll(0, -100).unwrap();
14 // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15 device.smooth_move_mouse(250, 250).unwrap();
16 //click the left mouse button
17 device.click(BTN_RIGHT).unwrap();
18 }
19
20 for _ in 1..2 {
21 thread::sleep(Duration::from_secs(1));
22
23 // scroll down by 100
24 device.scroll_y(-100).unwrap();
25 // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26 device.move_mouse(250, 250).unwrap();
27 //click the left mouse button
28 device.click(BTN_RIGHT).unwrap();
29 }
30}
pub fn buffered_gradual_move_mouse( &mut self, x: Coord, y: Coord, ) -> Vec<EventParams> ⓘ
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 26)
6fn main() {
7 let mut device = VirtualDevice::default().unwrap();
8
9 for _ in 1..3 {
10 thread::sleep(Duration::from_secs(1));
11
12 // gradually scroll down by 100
13 device.smooth_scroll(0, -100).unwrap();
14 // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15 device.smooth_move_mouse(250, 250).unwrap();
16 //click the left mouse button
17 device.click(BTN_RIGHT).unwrap();
18 }
19
20 for _ in 1..2 {
21 thread::sleep(Duration::from_secs(1));
22
23 // scroll down by 100
24 device.scroll_y(-100).unwrap();
25 // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26 device.move_mouse(250, 250).unwrap();
27 //click the left mouse button
28 device.click(BTN_RIGHT).unwrap();
29 }
30}
pub fn scroll_raw_x(&mut self, value: Coord) -> EmptyResult
pub fn scroll_raw_y(&mut self, value: Coord) -> EmptyResult
pub fn buffered_scroll_x(&mut self, value: Coord) -> Vec<EventParams> ⓘ
pub fn buffered_scroll_y(&mut self, value: Coord) -> Vec<EventParams> ⓘ
pub fn scroll_x(&mut self, value: Coord) -> EmptyResult
pub fn gradual_scroll_raw(&mut self, x: Coord, y: Coord) -> Result<()>
Sourcepub fn smooth_scroll(&mut self, x: Coord, y: Coord) -> Result<()>
pub fn smooth_scroll(&mut self, x: Coord, y: Coord) -> Result<()>
Examples found in repository?
examples/mouse.rs (line 13)
6fn main() {
7 let mut device = VirtualDevice::default().unwrap();
8
9 for _ in 1..3 {
10 thread::sleep(Duration::from_secs(1));
11
12 // gradually scroll down by 100
13 device.smooth_scroll(0, -100).unwrap();
14 // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15 device.smooth_move_mouse(250, 250).unwrap();
16 //click the left mouse button
17 device.click(BTN_RIGHT).unwrap();
18 }
19
20 for _ in 1..2 {
21 thread::sleep(Duration::from_secs(1));
22
23 // scroll down by 100
24 device.scroll_y(-100).unwrap();
25 // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26 device.move_mouse(250, 250).unwrap();
27 //click the left mouse button
28 device.click(BTN_RIGHT).unwrap();
29 }
30}
pub fn buffered_gradual_scroll( &mut self, x: Coord, y: Coord, ) -> Vec<EventParams> ⓘ
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 24)
6fn main() {
7 let mut device = VirtualDevice::default().unwrap();
8
9 for _ in 1..3 {
10 thread::sleep(Duration::from_secs(1));
11
12 // gradually scroll down by 100
13 device.smooth_scroll(0, -100).unwrap();
14 // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15 device.smooth_move_mouse(250, 250).unwrap();
16 //click the left mouse button
17 device.click(BTN_RIGHT).unwrap();
18 }
19
20 for _ in 1..2 {
21 thread::sleep(Duration::from_secs(1));
22
23 // scroll down by 100
24 device.scroll_y(-100).unwrap();
25 // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26 device.move_mouse(250, 250).unwrap();
27 //click the left mouse button
28 device.click(BTN_RIGHT).unwrap();
29 }
30}
pub fn buffered_press(&mut self, button: Button) -> Vec<EventParams> ⓘ
pub fn buffered_release(&mut self, button: Button) -> Vec<EventParams> ⓘ
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)
6fn main() {
7 let mut device = VirtualDevice::default().unwrap();
8
9 for _ in 1..3 {
10 thread::sleep(Duration::from_secs(1));
11
12 // gradually scroll down by 100
13 device.smooth_scroll(0, -100).unwrap();
14 // gradually move cursor 250 pixels up and 250 pixels to the right from the current position
15 device.smooth_move_mouse(250, 250).unwrap();
16 //click the left mouse button
17 device.click(BTN_RIGHT).unwrap();
18 }
19
20 for _ in 1..2 {
21 thread::sleep(Duration::from_secs(1));
22
23 // scroll down by 100
24 device.scroll_y(-100).unwrap();
25 // instantly move cursor 250 pixels up and 250 pixels to the right from the current position
26 device.move_mouse(250, 250).unwrap();
27 //click the left mouse button
28 device.click(BTN_RIGHT).unwrap();
29 }
30}
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