Struct uiautomation::core::UIMatcher

source ·
pub struct UIMatcher { /* private fields */ }
Expand description

Defines filter conditions to match specific UI Element.

UIMatcher can find first element or find all elements.

Implementations§

source§

impl UIMatcher

source

pub fn new(automation: UIAutomation) -> Self

Creates a matcher with automation.

source

pub fn mode(self, search_mode: UIMatcherMode) -> Self

Sets the searching mode. UIMatcherMode::Control is default mode.

source

pub fn from(self, element: UIElement) -> Self

Sets the root element of the UIAutomation tree whitch should be searched from.

The root element is desktop by default.

source

pub fn from_ref(self, element: &UIElement) -> Self

Sets the root element of the UIAutomation tree whitch should be searched from. The element is cloned internally.

The root element is desktop by default.

source

pub fn depth(self, depth: u32) -> Self

Sets the depth of the search path. The default depth is 7.

source

pub fn timeout(self, timeout: u64) -> Self

Sets the the time in millionseconds for matching element. The default timeout is 3000 millionseconds(3 seconds).

The UIMatcher will not retry to find when you set timeout to 0.

A timeout error will occur after this time.

source

pub fn interval(self, interval: u64) -> Self

Set the interval time in millionseconds for retrying. The default interval time is 100 millionseconds.

source

pub fn filter(self, filter: Box<dyn MatcherFilter>) -> Self

Appends a filter condition which is used as and logic.

source

pub fn filter_fn<F>(self, f: Box<F>) -> Self
where F: Fn(&UIElement) -> Result<bool> + 'static,

Appends a filter function which is used as and logic.

§Examples:
use uiautomation::core::UIAutomation;
use uiautomation::core::UIElement;
 
let automation = UIAutomation::new().unwrap();
let matcher = automation.create_matcher().filter_fn(Box::new(|e: &UIElement| {
    let framework_id = e.get_framework_id()?;
    let class_name = e.get_classname()?;
     
    Ok("Win32" == framework_id && class_name.starts_with("Shell"))
})).timeout(0);
let element = matcher.find_first();
assert!(element.is_ok());
source

pub fn name<S: Into<String>>(self, name: S) -> Self

Append a filter whitch match specific casesensitive name.

source

pub fn contains_name<S: Into<String>>(self, name: S) -> Self

Append a filter whitch name contains specific text (ignore casesensitive).

source

pub fn match_name<S: Into<String>>(self, name: S) -> Self

Append a filter whitch matches specific name (ignore casesensitive).

source

pub fn classname<S: Into<String>>(self, classname: S) -> Self

Filters by classname.

source

pub fn control_type(self, control_type: ControlType) -> Self

Filters by control type.

source

pub fn reset(self) -> Self

Clears all filters.

source

pub fn debug(self, debug: bool) -> Self

Set debug as true to enable debug mode. The debug mode is false by default.

source

pub fn find_first(&self) -> Result<UIElement>

Finds first element.

source

pub fn find_all(&self) -> Result<Vec<UIElement>>

Finds all elements.

Trait Implementations§

source§

impl Debug for UIMatcher

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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>,

§

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>,

§

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.