Struct macmatic::Bot

source ·
pub struct Bot {
    pub window: Option<Window>,
    /* private fields */
}
Expand description

The Bot struct provides automation capabilities for interacting with a window.

Fields§

§window: Option<Window>

The Window that the Bot interacts with.

Implementations§

source§

impl Bot

source

pub fn new() -> Bot

Creates a new instance of Bot.

source

pub fn set_window_from_name(&mut self, name: &str)

Sets the window based on the specified name.

source

pub fn set_window_from_regex(&mut self, regex: &str)

Sets the window based on the specified regex.

source

pub fn set_window_from_id(&mut self, id: i64)

Sets the window based on the specified id.

source

pub fn set_controller(&mut self, controller: Enigo)

Sets the Enigo controller.

source

pub fn set_high_dpi_ratio(&mut self, ratio: u32)

Sets High DPI mode (for standard screen: 1, for Retina-like: 2).

source

pub fn set_wait_time(&mut self, duration: Duration)

Sets the delay between mouse move and mouse down and up.

source

pub fn set_capture_frequency(&mut self, value: f32)

Sets the number of captures per seconds.

source

pub fn sleep(&mut self, millis: u64)

Waits for the specified duration in milliseconds.

source

pub fn click(&mut self, relative_x: u32, relative_y: u32) -> Result<(), Error>

Clicks the mouse button at the specified coordinates relative to the window.

source

pub fn mouse_down_on( &mut self, relative_x: u32, relative_y: u32 ) -> Result<(), Error>

Pushes down the mouse button at the specified coordinates relative to the window.

source

pub fn mouse_up_on( &mut self, relative_x: u32, relative_y: u32 ) -> Result<(), Error>

Releases the mouse button at the specified coordinates relative to the window.

source

pub fn activate_window(&mut self) -> Result<(), Error>

Clicks at the top of the bottom to activate the window.

source

pub fn find(&mut self, template: &Path) -> Result<Rect, Error>

Searches for a a specified image within the window and returns the Rect coordinates.

source

pub fn click_on_image( &mut self, template: &Path, time_out: u64 ) -> Result<(u32, u32), Error>

Searches for a specified image within the window and clicks at its center.

source

pub fn key_down(&mut self, key: Key) -> Result<(), Error>

Presses down the given key.

source

pub fn key_up(&mut self, key: Key) -> Result<(), Error>

Releases the given key.

source

pub fn key_click(&mut self, key: Key) -> Result<(), Error>

Presses and release the key.

source

pub fn key_sequence(&mut self, text: &str) -> Result<(), Error>

Types a string.

source

pub fn write(&mut self, text: &str) -> Result<(), Error>

Types a string (alias to key_sequence).

source

pub fn writeln(&mut self, text: &str) -> Result<(), Error>

Types a string followed by return.

Trait Implementations§

source§

impl Debug for Bot

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Bot

§

impl !Send for Bot

§

impl !Sync for Bot

§

impl Unpin for Bot

§

impl UnwindSafe for Bot

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.