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
impl UIMatcher
sourcepub fn new(automation: UIAutomation) -> Self
pub fn new(automation: UIAutomation) -> Self
Creates a matcher with automation
.
sourcepub fn mode(self, search_mode: UIMatcherMode) -> Self
pub fn mode(self, search_mode: UIMatcherMode) -> Self
Sets the searching mode. UIMatcherMode::Control
is default mode.
sourcepub fn from(self, element: UIElement) -> Self
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.
sourcepub fn from_ref(self, element: &UIElement) -> Self
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.
sourcepub fn depth(self, depth: u32) -> Self
pub fn depth(self, depth: u32) -> Self
Sets the depth of the search path. The default depth is 7
.
sourcepub fn timeout(self, timeout: u64) -> Self
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.
sourcepub fn interval(self, interval: u64) -> Self
pub fn interval(self, interval: u64) -> Self
Set the interval time in millionseconds for retrying. The default interval time is 100 millionseconds.
sourcepub fn filter(self, filter: Box<dyn MatcherFilter>) -> Self
pub fn filter(self, filter: Box<dyn MatcherFilter>) -> Self
Appends a filter condition which is used as and
logic.
sourcepub fn filter_fn<F>(self, f: Box<F>) -> Self
pub fn filter_fn<F>(self, f: Box<F>) -> Self
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());
sourcepub fn name<S: Into<String>>(self, name: S) -> Self
pub fn name<S: Into<String>>(self, name: S) -> Self
Append a filter whitch match specific casesensitive name.
sourcepub fn contains_name<S: Into<String>>(self, name: S) -> Self
pub fn contains_name<S: Into<String>>(self, name: S) -> Self
Append a filter whitch name contains specific text (ignore casesensitive).
sourcepub fn match_name<S: Into<String>>(self, name: S) -> Self
pub fn match_name<S: Into<String>>(self, name: S) -> Self
Append a filter whitch matches specific name (ignore casesensitive).
sourcepub fn control_type(self, control_type: ControlType) -> Self
pub fn control_type(self, control_type: ControlType) -> Self
Filters by control type.
sourcepub fn debug(self, debug: bool) -> Self
pub fn debug(self, debug: bool) -> Self
Set debug
as true
to enable debug mode. The debug mode is false
by default.
sourcepub fn find_first(&self) -> Result<UIElement>
pub fn find_first(&self) -> Result<UIElement>
Finds first element.