XDo

Struct XDo 

Source
pub struct XDo { /* private fields */ }
Expand description

The main handle type which provides access to the various operations.

Implementations§

Source§

impl XDo

Source

pub fn new(display: Option<&str>) -> Result<XDo, CreationError>

Creates a new XDo instance.

§Parameters

display - An optional string display name, such as ":0". If None, uses $DISPLAY.

§Returns

Returns a new XDo instance, or a CreationError on error.

Examples found in repository?
examples/mousemove.rs (line 6)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.move_mouse(0, 0, 0).unwrap();
8}
More examples
Hide additional examples
examples/typehello.rs (line 6)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.enter_text("Hello, World!", 250_000).unwrap();
8}
examples/autoclicker.rs (line 7)
6fn main() {
7    let xdo = XDo::new(None).unwrap();
8
9    for _ in 0..5 {
10        xdo.click(1).unwrap();
11        std::thread::sleep(Duration::from_secs(1));
12    }
13}
examples/drag_drop.rs (line 6)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.mouse_down(1).unwrap();
8    xdo.move_mouse_relative(150, 150).unwrap();
9    xdo.mouse_up(1).unwrap();
10}
examples/mousesquare.rs (line 14)
13fn main() {
14    let xdo = XDo::new(None).unwrap();
15    move_it(&xdo, 10, 0, 20);
16    move_it(&xdo, 0, 10, 20);
17    move_it(&xdo, -10, 0, 20);
18    move_it(&xdo, 0, -10, 20);
19}
examples/yes.rs (line 7)
6fn main() {
7    let xdo = XDo::new(None).unwrap();
8    for _ in 0..10 {
9        xdo.send_keysequence("y", 0).unwrap();
10        xdo.send_keysequence("Return", 0).unwrap();
11        std::thread::sleep(Duration::from_millis(100));
12    }
13}
Source

pub fn move_mouse(&self, x: i32, y: i32, screen: i32) -> OpResult

Moves the mouse to the specified position.

Examples found in repository?
examples/mousemove.rs (line 7)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.move_mouse(0, 0, 0).unwrap();
8}
Source

pub fn move_mouse_relative(&self, x: i32, y: i32) -> OpResult

Moves the mouse relative to the current position.

Examples found in repository?
examples/drag_drop.rs (line 8)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.mouse_down(1).unwrap();
8    xdo.move_mouse_relative(150, 150).unwrap();
9    xdo.mouse_up(1).unwrap();
10}
More examples
Hide additional examples
examples/mousesquare.rs (line 8)
6fn move_it(xdo: &XDo, rel_x: i32, rel_y: i32, times: i32) {
7    for _ in 0..times {
8        xdo.move_mouse_relative(rel_x, rel_y).unwrap();
9        std::thread::sleep(Duration::from_millis(10));
10    }
11}
Source

pub fn click(&self, button: i32) -> OpResult

Does a mouse click.

Examples found in repository?
examples/autoclicker.rs (line 10)
6fn main() {
7    let xdo = XDo::new(None).unwrap();
8
9    for _ in 0..5 {
10        xdo.click(1).unwrap();
11        std::thread::sleep(Duration::from_secs(1));
12    }
13}
Source

pub fn mouse_down(&self, button: i32) -> OpResult

Holds a mouse button down.

Examples found in repository?
examples/drag_drop.rs (line 7)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.mouse_down(1).unwrap();
8    xdo.move_mouse_relative(150, 150).unwrap();
9    xdo.mouse_up(1).unwrap();
10}
Source

pub fn mouse_up(&self, button: i32) -> OpResult

Releases a mouse button.

Examples found in repository?
examples/drag_drop.rs (line 9)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.mouse_down(1).unwrap();
8    xdo.move_mouse_relative(150, 150).unwrap();
9    xdo.mouse_up(1).unwrap();
10}
Source

pub fn enter_text(&self, text: &str, delay_microsecs: u32) -> OpResult

Types the specified text.

Examples found in repository?
examples/typehello.rs (line 7)
5fn main() {
6    let xdo = XDo::new(None).unwrap();
7    xdo.enter_text("Hello, World!", 250_000).unwrap();
8}
Source

pub fn send_keysequence(&self, sequence: &str, delay_microsecs: u32) -> OpResult

Does the specified key sequence.

Examples found in repository?
examples/yes.rs (line 9)
6fn main() {
7    let xdo = XDo::new(None).unwrap();
8    for _ in 0..10 {
9        xdo.send_keysequence("y", 0).unwrap();
10        xdo.send_keysequence("Return", 0).unwrap();
11        std::thread::sleep(Duration::from_millis(100));
12    }
13}
Source

pub fn send_keysequence_up( &self, sequence: &str, delay_microsecs: u32, ) -> OpResult

Releases the specified key sequence.

Source

pub fn send_keysequence_down( &self, sequence: &str, delay_microsecs: u32, ) -> OpResult

Presses the specified key sequence down.

Trait Implementations§

Source§

impl Drop for XDo

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for XDo

§

impl RefUnwindSafe for XDo

§

impl !Send for XDo

§

impl !Sync for XDo

§

impl Unpin for XDo

§

impl UnwindSafe for XDo

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.