AXUIElement

Struct AXUIElement 

Source
pub struct AXUIElement { /* private fields */ }
Available on crate feature AXUIElement only.
Expand description

A structure used to refer to an accessibility object.

An accessibility object provides information about the user interface object it represents. This information includes the object’s position in the accessibility hierarchy, its position on the display, details about what it is, and what actions it can perform. Accessibility objects respond to messages sent by assistive applications and send notifications that describe state changes.

See also Apple’s documentation

Implementations§

Source§

impl AXUIElement

Source

pub unsafe fn copy_attribute_names( &self, names: NonNull<*const CFArray>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns a list of all the attributes supported by the specified accessibility object.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter names: On return, an array containing the accessibility object’s attribute names.

Returns: If unsuccessful, AXUIElementCopyAttributeNames may return one of the following error codes, among others:

kAXErrorAttributeUnsupported
The specified AXUIElementRef does not support the specified attribute.
kAXErrorIllegalArgument
One or both of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorFailure
There was a system memory failure.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

names must be a valid pointer.

Source

pub unsafe fn copy_attribute_value( &self, attribute: &CFString, value: NonNull<*const CFType>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns the value of an accessibility object’s attribute.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter attribute: The attribute name.

Parameter value: On return, the value associated with the specified attribute.

Returns: If unsuccessful, AXUIElementCopyAttributeValue may return one of the following error codes, among others:

kAXErrorAttributeUnsupported
The specified AXUIElementRef does not support the specified attribute.
kAXErrorNoValue
The specified attribute does not have a value.
kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

value must be a valid pointer.

Source

pub unsafe fn attribute_value_count( &self, attribute: &CFString, count: NonNull<CFIndex>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns the count of the array of an accessibility object’s attribute value.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter attribute: The attribute name.

Parameter count: On return, the size of the array that is the attribute’s value.

Returns: If unsuccessful, AXUIElementGetAttributeValueCount may return one of the following error codes, among others:

kAXErrorIllegalArgument
The attribute's value is not an array or one of the other arguments is an illegal value.
kAXErrorAttributeUnsupported
The specified AXUIElementRef does not support the specified attribute.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

count must be a valid pointer.

Source

pub unsafe fn copy_attribute_values( &self, attribute: &CFString, index: CFIndex, max_values: CFIndex, values: NonNull<*const CFArray>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns an array of attribute values for the accessibility object’s attribute, starting at the specified index.

This function is useful for dealing with large arrays, for example, a table view with a large number of children.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter attribute: The attribute name.

Parameter index: The index into the array.

Parameter maxValues: The maximum number of values you want (this may be more or less than the number of values associated with the attribute).

Parameter values: On return, the attribute values you requested. If maxValues is greater than the number of values associated with the attribute, the values array will contain values found between index and the end of the attribute’s array, inclusive.

Returns: If unsuccessful, AXUIElementCopyAttributeValues may return one of the following error codes, among others:

kAXErrorIllegalArgument
The attribute's value is not array, the index or maxValues arguments are outside the array's range, or one of the other arguments is an illegal value.
kAXErrorNoValue
The specified attribute does not have a value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

values must be a valid pointer.

Source

pub unsafe fn is_attribute_settable( &self, attribute: &CFString, settable: NonNull<u8>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns whether the specified accessibility object’s attribute can be modified.

If you receive a kAXErrorCannotComplete error from this function, you might want to repeat the request or change the timeout value.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter attribute: The attribute name.

Parameter settable: On return, a Boolean value indicating whether the attribute is settable.

Returns: If unsuccessful, AXUIElementIsAttributeSettable may return one of the following error codes, among others:

kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way (often due to a timeout).
kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorAttributeUnsupported
The specified AXUIElementRef does not support the specified attribute.
kAXErrorNoValue
The specified attribute does not have a value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

settable must be a valid pointer.

Source

pub unsafe fn set_attribute_value( &self, attribute: &CFString, value: &CFType, ) -> AXError

Available on crate features HIServices and AXError only.

Sets the accessibility object’s attribute to the specified value.

You can send and receive many different CFTypeRefs using the accessibility API. These include all CFPropertyListRef types, AXUIElementRef, AXValueRef, AXTextMarkerRef, AXTextMarkerRangeRef, CFNullRef, CFAttributedStringRef, and CRURLRef.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter attribute: The attribute name.

Parameter value: The new value for the attribute.

Returns: If unsuccessful, AXUIElementSetAttributeValue may return one of the following error codes, among others:

kAXErrorIllegalArgument
The value is not recognized by the accessible application or one of the other arguments is an illegal value.
kAXErrorAttributeUnsupported
The specified AXUIElementRef does not support the specified attribute.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

value should be of the correct type.

Source

pub unsafe fn copy_multiple_attribute_values( &self, attributes: &CFArray, options: AXCopyMultipleAttributeOptions, values: NonNull<*const CFArray>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns the values of multiple attributes in the accessibility object.

If the specified AXUIElementRef does not support an attribute passed in the attributes array, the returned array can contain an error or CFNull at the corresponding position.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter attributes: An array of attribute names.

Parameter options: A value that tells AXUIElementCopyMultipleAttributeValues how to handle errors.

§Parameter values: On return, an array in which each position contains the value of the attribute that is in the corresponding position in the passed-in attributes array (or CFNull). If options = 0, the values array can contain an AXValueRef of type kAXValueAXErrorType in the corresponding position. If options
kAXCopyMultipleAttributeOptionStopOnError , this function will return immediately when it gets an error.

Returns: If unsuccessful, AXUIElementCopyMultipleAttributeValues may return one of the following error codes, among others:

kAXErrorIllegalArgument
One of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety
  • attributes generic must be of the correct type.
  • values must be a valid pointer.
Source

pub unsafe fn copy_parameterized_attribute_names( &self, names: NonNull<*const CFArray>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns a list of all the parameterized attributes supported by the specified accessibility object.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter names: On return, an array containing the accessibility object’s parameterized attribute names.

Returns: If unsuccessful, AXUIElementCopyParameterizedAttributeNames may return one of the following error codes, among others:

kAXErrorAttributeUnsupported or kAXErrorParameterizedAttributeUnsupported
The specified AXUIElementRef does not support the specified parameterized attribute.
kAXErrorIllegalArgument
One or both of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorFailure
There was some sort of system memory failure.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

names must be a valid pointer.

Source

pub unsafe fn copy_parameterized_attribute_value( &self, parameterized_attribute: &CFString, parameter: &CFType, result: NonNull<*const CFType>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns the value of an accessibility object’s parameterized attribute.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter parameterizedAttribute: The parameterized attribute.

Parameter parameter: The parameter.

Parameter result: On return, the value of the parameterized attribute.

Returns: If unsuccessful, AXUIElementCopyParameterizedAttributeValue may return one of the following error codes, among others:

kAXErrorAttributeUnsupported or kAXErrorParameterizedAttributeUnsupported
The specified AXUIElementRef does not support the specified parameterized attribute.
kAXErrorNoValue
The specified parameterized attribute does not have a value.
kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety
  • parameter should be of the correct type.
  • result must be a valid pointer.
Source

pub unsafe fn copy_action_names( &self, names: NonNull<*const CFArray>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns a list of all the actions the specified accessibility object can perform.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter names: On return, an array of actions the accessibility object can perform (empty if the accessibility object supports no actions).

Returns: If unsuccessful, AXUIElementCopyActionNames may return one of the following error codes, among others:

kAXErrorIllegalArgument
One or both of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorFailure
There was some sort of system memory failure.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

names must be a valid pointer.

Source

pub unsafe fn copy_action_description( &self, action: &CFString, description: NonNull<*const CFString>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns a localized description of the specified accessibility object’s action.

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter action: The action to be described.

Parameter description: On return, a string containing the description of the action.

Returns: If unsuccessful, AXUIElementCopyActionDescription may return one of the following error codes, among others:

kAXErrorActionUnsupported
The specified AXUIElementRef does not support the specified action (you will also receive this error if you pass in the system-wide accessibility object).
kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

description must be a valid pointer.

Source

pub unsafe fn perform_action(&self, action: &CFString) -> AXError

Available on crate features HIServices and AXError only.

Requests that the specified accessibility object perform the specified action.

It is possible to receive the kAXErrorCannotComplete error code from this function because accessible applications often need to perform some sort of modal processing inside their action callbacks and they may not return within the timeout value set by the accessibility API. This does not necessarily mean that the function has failed, however. If appropriate, your assistive application can try to call this function again. Also, you may be able to increase the timeout value (see

 AXUIElementSetMessagingTimeout AXUIElementSetMessagingTimeout

).

Parameter element: The AXUIElementRef representing the accessibility object.

Parameter action: The action to be performed.

Returns: If unsuccessful, AXUIElementPerformAction may return one of the following error codes, among others:

kAXErrorActionUnsupported
The specified AXUIElementRef does not support the specified action (you will also receive this error if you pass in the system-wide accessibility object).
kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way or the application has not yet responded.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
Source

pub unsafe fn copy_element_at_position( &self, x: c_float, y: c_float, element: NonNull<*const AXUIElement>, ) -> AXError

Available on crate features HIServices and AXError only.

Returns the accessibility object at the specified position in top-left relative screen coordinates.

This function does hit-testing based on window z-order (that is, layering). If one window is on top of another window, the returned accessibility object comes from whichever window is topmost at the specified location. Note that if the system-wide accessibility object is passed in the application parameter, the position test is not restricted to a particular application.

Parameter application: The AXUIElementRef representing the application that contains the screen coordinates (or the system-wide accessibility object).

Parameter x: The horizontal position.

Parameter y: The vertical position.

Parameter element: On return, the accessibility object at the position specified by x and y.

Returns: If unsuccessful, AXUIElementCopyElementAtPosition may return one of the following error codes, among others:

kAXErrorNoValue
There is no accessibility object at the specified position.
kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.
§Safety

element must be a valid pointer.

Source

pub unsafe fn new_application(pid: pid_t) -> CFRetained<AXUIElement>

Available on crate features HIServices and libc only.

Creates and returns the top-level accessibility object for the application with the specified process ID.

Parameter pid: The process ID of an application.

Returns: The AXUIElementRef representing the top-level accessibility object for the application with the specified process ID.

Source

pub unsafe fn new_system_wide() -> CFRetained<AXUIElement>

Available on crate feature HIServices only.

Returns an accessibility object that provides access to system attributes.

This is useful for things like finding the focused accessibility object regardless of which application is currently active.

Returns: The AXUIElementRef representing the system-wide accessibility object.

Source

pub unsafe fn pid(&self, pid: NonNull<pid_t>) -> AXError

Available on crate features HIServices and AXError and libc only.

Returns the process ID associated with the specified accessibility object.

Parameter element: The AXUIElementRef representing an accessibility object.

Parameter pid: On return, the process ID associated with the specified accessibility object.

Returns: If unsuccessful, AXUIElementGetPid may return one of the following error codes, among others:

kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
§Safety

pid must be a valid pointer.

Source

pub unsafe fn set_messaging_timeout( &self, timeout_in_seconds: c_float, ) -> AXError

Available on crate features HIServices and AXError only.

Sets the timeout value used in the accessibility API.

Pass the system-wide accessibility object (see

 AXUIElementCreateSystemWide AXUIElementCreateSystemWide

) if you want to set the timeout globally for this process. Setting the timeout on another accessibility object sets it only for that object, not for other accessibility objects that are equal to it.

Setting timeoutInSeconds to 0 for the system-wide accessibility object resets the global timeout to its default value. Setting timeoutInSeconds to 0 for any other accessibility object makes that element use the current global timeout value.

Parameter element: The AXUIElementRef representing an accessibility object.

Parameter timeoutInSeconds: The number of seconds for the new timeout value.

Returns: If unsuccessful, AXUIElementSetMessagingTimeout may return one of the following error codes, among others:

kAXErrorIllegalArgument
One or more of the arguments is an illegal value (timeout values must be positive).
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
Source

pub unsafe fn post_keyboard_event( &self, key_char: CGCharCode, virtual_key: CGKeyCode, key_down: bool, ) -> AXError

👎Deprecated
Available on crate features HIServices and AXError and objc2-core-graphics only.

Posts keys to the specified application.

This is similar to

 //apple_ref/c/func/CGPostKeyboardEvent CGPostKeyboardEvent

(which synthesizes a low-level keyboard event on the local machine), but it allows you to specify the target application as opposed to always sending the events to the active application. If the system-wide accessibility object is passed in the application parameter, the event is sent to the active application.

You can only pass in the system-wide or application AXUIElementRef.

Parameter application: The AXUIElementRef representing the application (or the system-wide accessibility object).

Parameter keyChar: Parameter virtualKey: Parameter keyDown: Returns: If unsuccessful, AXUIElementPostKeyboardEvent may return one of the following error codes, among others:

kAXErrorIllegalArgument
One or more of the arguments is an illegal value.
kAXErrorInvalidUIElement
The AXUIElementRef is invalid.
kAXErrorFailure
There is some sort of system memory failure.
kAXErrorCannotComplete
The function cannot complete because messaging has failed in some way.
kAXErrorNotImplemented
The process does not fully support the accessibility API.

Methods from Deref<Target = CFType>§

Source

pub fn downcast_ref<T>(&self) -> Option<&T>
where T: ConcreteType,

Attempt to downcast the type to that of type T.

This is the reference-variant. Use CFRetained::downcast if you want to convert a retained type. See also ConcreteType for more details on which types support being converted to.

Source

pub fn retain_count(&self) -> usize

Get the reference count of the object.

This function may be useful for debugging. You normally do not use this function otherwise.

Beware that some things (like CFNumbers, small CFStrings etc.) may not have a normal retain count for optimization purposes, and can return usize::MAX in that case.

Trait Implementations§

Source§

impl AsRef<AXUIElement> for AXUIElement

Available on crate feature HIServices only.
Source§

fn as_ref(&self) -> &Self

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<AnyObject> for AXUIElement

Available on crate feature HIServices only.
Source§

fn as_ref(&self) -> &AnyObject

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<CFType> for AXUIElement

Available on crate feature HIServices only.
Source§

fn as_ref(&self) -> &CFType

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Borrow<AnyObject> for AXUIElement

Available on crate feature HIServices only.
Source§

fn borrow(&self) -> &AnyObject

Immutably borrows from an owned value. Read more
Source§

impl Borrow<CFType> for AXUIElement

Available on crate feature HIServices only.
Source§

fn borrow(&self) -> &CFType

Immutably borrows from an owned value. Read more
Source§

impl ConcreteType for AXUIElement

Available on crate feature HIServices only.
Source§

fn type_id() -> CFTypeID

Returns the unique type identifier for the AXUIElementRef type.

Returns: Returns a CFTypeID representing the AXUIElementRef type.

Source§

impl Debug for AXUIElement

Available on crate feature HIServices only.
Source§

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

Formats the value using the given formatter. Read more
Source§

impl Deref for AXUIElement

Available on crate feature HIServices only.
Source§

type Target = CFType

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Hash for AXUIElement

Available on crate feature HIServices only.
Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Message for AXUIElement

Available on crate feature HIServices only.
Source§

fn retain(&self) -> Retained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

impl PartialEq for AXUIElement

Available on crate feature HIServices only.
Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RefEncode for AXUIElement

Available on crate feature HIServices only.
Source§

const ENCODING_REF: Encoding

The Objective-C type-encoding for a reference of this type. Read more
Source§

impl Type for AXUIElement

Available on crate feature HIServices only.
Source§

fn retain(&self) -> CFRetained<Self>
where Self: Sized,

Increment the reference count of the receiver. Read more
Source§

fn as_concrete_TypeRef(&self) -> &Self

👎Deprecated: this is redundant
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_get_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::retain
Helper for easier transition from the core-foundation crate. Read more
Source§

fn as_CFTypeRef(&self) -> &CFType
where Self: AsRef<CFType>,

👎Deprecated: this is redundant (CF types deref to CFType)
Helper for easier transition from the core-foundation crate.
Source§

unsafe fn wrap_under_create_rule(ptr: *const Self) -> CFRetained<Self>
where Self: Sized,

👎Deprecated: use CFRetained::from_raw
Helper for easier transition from the core-foundation crate. Read more
Source§

impl Eq for AXUIElement

Available on crate feature HIServices only.

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

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