PFUIElement
IntroductionA concrete class representing a UI element in a running application. DiscussionA PFUIElement object represents a UI element on the screen in a running application, such as a menu, window or button. The PFApplicationUIElement subclass represents a root-level UI element—either an application or the system-wide element representing all running applications. The PFUIElement class implements all of the functionality of the accessibility API's AXUIElementRef object. A PFApplicationUIElement subclass implements additional AXUIElementRef functionality relating to the root application element and the system-wide element. PFUIElement objects fully support the accessibility API's actions, attributes, keystrokes and notifications. A client application can get the value of a PFUIElement object's attributes, set the value of its settable attributes, and perform any actions it supports. It can send keystrokes, including keyboard shortcuts, to the target application to control its focused UI element. And, by creating a PFObserver object, it can observe any application or UI element and receive notifications when changes occur. In this documentation, depending on context, "UI element" or "element" may refer either to a programmatic PFUIElement or PFApplicationUIElement object or to the user interface object in the running application that is represented by a PFUIElement or PFApplicationUIElement object. References to a "PFUIElement object" generally include a PFApplicationUIElement object, since the PFApplicationUIElement class is a subclass of PFUIElement. An application's UI elements are organized in a tree-like containment hierarchy of PFUIElement objects, with the root application element on one end and leaf elements on the screen such as buttons and checkboxes on the other. A target application's hierarchy can be navigated in either direction by traversing any element's parent and children. An application's individual elements can be read by getting their attributes, and in many cases they can be controlled by setting their attributes and performing actions on them and by sending keystrokes to the application. Methods are provided to obtain the application's root element given its path or its process identification number (PID) as an entry point into the tree, or, alternatively, to read the screen to obtain the root UI element of whatever application currently has a user interface object at a specified point on the screen. UI elements have attributes and, in many cases, actions identified by a key, a string that usually begins with the prefix "AX" as in "AXRole" or "AXPress". In a client assistive application, you normally use the NSString constants declared in the NSAccessibility informal protocol (in NSAccessibility.h, in the Cocoa AppKit framework). Alternatively, you can use the corresponding CFStringRef constants declared in the accessibility API headers and cast them to NSString*, or use the strings themselves. Some constants are omitted from NSAccessibility.h or from the accessibility API headers; if you can't find a desired constant in one of these headers, use a constant from the other header or the string itself. Note that some constants in these headers may be marked as obsolete; use only the non-obsolete constants or their string equivalents to maximize compatibility with future releases of macOS. (Most of the constants in the NSAccessibility informal protocol were deprecated in OS X Yosemite 10.10 in favor of the new formal protocols in NSAccessibilityProtocols.h. However, the deprecation was intended to apply to the way regular applications make their UI elements accessible, which is shifting from the old key-based approach to the new method-based protocol. Assistive applications should still use the key-based constants.) Some applications, such as the Finder and Safari, implement custom UI elements with custom actions and attributes that are not part of Apple's accessibility API. This framework is written so that you can read and manipulate them as well as Apple's built-in accessibility API actions and attributes. You may be able to identify the strings used to identify custom actions and attributes by reading an application's documentation or by examining the .strings files in its application bundle. You will find it much easier, however, to use UI Browser, available from PreForm Assistive Technologies, LLC at pfiddlesoft.com/uibrowser. Many methods return PFUIElement or PFApplicationUIElement objects. Think of these methods as factories that can be called upon to churn out these objects as often as needed, whenever needed, even if you use them only for a moment. Separate PFUIElement or PFApplicationUIElement objects representing the same UI element in the running application are interchangeable. Whether they represent the same element can be tested using Clients may subclass PFUIElement for applications that also subclass PFApplicationUIElement, by registering the PFUIElement subclass for the application's PID using the methods described in the discussion of PFApplicationUIElement subclassing. Before a client application can make use of this class in OS X Mavericks 10.9 or newer, access must be granted to it using the new per-application trust mechanism in the Accessibility list in the Security & Privacy preference's Privacy pane in System Preferences. Global access and the old per-application trust mechanism no longer work in Mavericks or newer. In OS X Mountain Lion 10.8 and older, the global "Enable access for assistive devices" setting in the Accessibility (or Universal Access) pane of System Preferences must be turned on, or the client application must be made a trusted process through use of the accessibility API's GroupsINITIALIZATIONGroup members:
ATTRIBUTE UTILITIESGroup members:
INSTANCE UTILITIESGroup members:
ATTRIBUTESGroup members:
CLASS UTILITIESGroup members:
DEBUGGING UTILITIESGroup members:
UI ELEMENTSGroup members:
NOTIFICATIONSGroup members:
ACTION UTILITIESGroup members:
ACTIONSGroup members:
NOTIFICATION UTILITIESGroup members:
DELEGATE ACCESSORSGroup members:
UI ELEMENT UTILITIESGroup members:
Methods
actionDefinitionsClass method returns an NSDictionary object containing information about all accessibility actions. + (NSDictionary *)actionDefinitions; Return ValueA dictionary containing information about all accessibility actions. DiscussionThis class method returns a dictionary containing the technical names and other features of all accessibility actions as listed in the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist starting with Mac OS X 10.7 (Lion). It reads information from the actions dictionary in the plist file. actionsReturns the technical, non-localized names of all actions implemented by the receiver. - (NSArray<NSString *> *)actions; Return ValueAn array of NSString objects, or an empty array if the receiver does not recognize any actions. DiscussionThe accessibility API implements relatively few actions, and many UI elements do not support any actions at all. Specific applications may implement custom actions, such as the AXOpen action in the Finder, and they are included in the array returned by this method. Sometimes performing an action and setting an attribute would achieve the same goal. In such cases, Apple generally prefers the action and makes the attribute unsettable. The prime example is checkboxes, whose value you set by sending them an AXPress action. A client application can test whether a UI element exists and supports a specific action with -existsAction:; it can get a localized description of an action with -descriptionForAction:; and it can perform an action with -performAction:. The following actions are supported by the accessibility API (obsolete actions are omitted):
actionsForRole:andSubrole:Class method returns an NSArray containing the technical names of all accessibility actions that should be supported by a UI element with the specified role and subrole. + (NSArray<NSString *> *)actionsForRole:(NSString *)role andSubrole:(nullable NSString *)subrole; Parameters
Return ValueAn array of NSString objects, or an empty array if a UI element with the specified role and subrole should not support any actions. DiscussionThis class method returns an array listing all of the accessibility actions that a UI element with the specified role and subrole should support. This is general information obtained from the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist starting with Mac OS X 10.7 (Lion). It does not guarantee that any particular UI element does in fact support the actions. As of OS X Mavericks 10.9, it is not known whether the role_actions array has been fully validated by Apple and is complete. activateApplicationBrings the element's application to the front, returning - (BOOL)activateApplication; DiscussionThe element's application must be frontmost in order for some PFAssistive framework methods to be used. For example, it is necessary to make an application's menu visible before its menu items can be sent AXPress actions, and menus are not visible when the application is not frontmost. The accessibility API is designed to emulate the experience of a typical user, and UI elements are generally not usable when they are not visible on the screen. If the application is not a user application, this method calls Application Services functions that were deprecated in OS X Mountain Lion 10.8 and/or OS X Mavericks 10.9 because the corresponding NSRunningApplication methods do not work with system or background applications. Deprecation warnings are suppressed during compilation. If you call this method, it is your responsibility to return the client application to the front, if appropriate. You can call NSApplication's [DELETE THIS:] If the target application is background-only, this method returns applicationElementCreates and returns a root application UI element object representing the application owning the receiver. - (nullable PFApplicationUIElement *)applicationElement; Return ValueThe receiver's root appplication UI element, of class PFApplicationUIElement or a subclass, or nil if the element's PID is 0 (which would be invalid). DiscussionIt is sometimes useful to have a reference to the root application UI element as a PFApplicationUIElement or subclass object, in order to access features that are unique to that subclass of PFUIElement. To ensure that this method returns an object of the correct class when PFApplicationUIElement is subclassed, an object of the subclass type must be created and initialized, using the PFApplicationUIElement designated initializer or any convenience initializer that calls the designated initializer, before this method is called. The designated initializer registers the subclass for the target application's PID. See the discussion of subclass support in the PFAppliationUIElement class documentation for details. attributeDefinitionsClass method returns an NSDictionary object containing information about all accessibility attributes. + (NSDictionary *)attributeDefinitions; Return ValueA dictionary containing information about all accessibility attributes. DiscussionThis class method returns a dictionary containing the technical names and other features of all accessibility attributes as listed in the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist starting with Mac OS X 10.7 (Lion). It reads information from the attributes dictionary in the plist file. attributedStringFromAXAttributedString:Returns an attributed string suitable for display in a text view, converted from an accessibility attributed string. - (NSAttributedString *) attributedStringFromAXAttributedString:(NSAttributedString *)AXAttributedString; ParametersReturn ValueAn NSAttributedString object with standard Cocoa text system attributes. DiscussionThe attributed string returned by this method is a standard text system attributed string suitable for display in a text view based on NSTextStorage. It is converted from an accessibility text attributed string passed to it from the -AXAttributedStringForRange: parameterized attribute method. The conversion is lossy, as described below. Use this method only when you wish to display a reasonable facsimile of the accessibility attributed string. For an assistive application, use the accessibility attributed string and its attributes, instead. An accessibility text attributed string is an NSAttributedString in the sense that it has a dictionary of attributes and responds to NSAttributedString methods. However, its attributes, declared in AXTextAttributedString.h, differ from the standard text system attributes, and it therefore cannot be used for display without first converting it using this method. An accessibility text attributed string omits many appearance-related attributes of a standard text system attributed string that do not convey meaningful information in the accessibility context, so an attributed string returned by this method may not look identical to the original attributed string in the target application. For example, baseline offset, kerning and ligature information is omitted, and double strikethroughs are not distinguished from single strikethroughs. Other standard text system attributes are included, such as foreground and background color, superscript and subscript, underline, strikethrough, shadow, link, and text attachment. An accessibility text attributed string also includes some attributes that are not recognized by the standard text system, namely, natural language, replacement string, and misspelled string, three list item attributes introduced in OS X El Capitan 10.11, the text alignment attribute introduced in macOS Sierra 10.12, and the language, custom and annotation attributes introduced in macOS High Sierra 10.13. attributesReturns an array of the technical, non-localized names of all attributes recognized by the receiver. - (NSArray<NSString *> *)attributes; Return ValueAn array of NSString objects, or an empty array if the receiver does not recognize any attributes. DiscussionCocoa and Carbon target applications respond differently to this method. In general, Carbon target applications return only those attributes that are implemented by the receiving UI element, and all such attributes therefore have a value. Cocoa target applications return all attributes implemented in the receiver's class, whether or not a particular attribute for a particular UI element has a value. In cases where an attribute is not implemented, or is implemented but does not contain a value, the PFUIElement accessor method for that attribute returns The preferred and most efficient way to get or set the value of an attribute of the receiver is to send one of the specific attribute accessor messages, such as -AXRole declared in the Attributes category. The names of these accessor methods are identical to the technical, non-localized attribute strings declared in the accessibility API and returned by this method, including the "AX" prefix. The accessor methods are convenient to use and descriptive when you know the name of the attribute you want to access. The PFAssistive framework implements accessor methods for all attributes declared in the Cocoa and Carbon accessibility APIs (except those marked obsolete). While many specific attribute accessor methods apply to almost any kind of UI element, others apply only to particular kinds of UI elements. In addition, applications are free to implement new kinds of UI elements and new attributes. Apple encourages developers to minimize the number of new attributes by reusing existing attributes for analogous new purposes wherever appropriate. As time goes by, therefore, existing attributes may apply to more and more kinds of UI elements. When in doubt, test the return value of an attribute for Another way to get or set the value of a non-parameterized attribute of the receiver is to send the generic messages -valueForAttribute: and -setValue:forAttribute:. They use key-value coding with keys generated by -nonParameterizedAttributes. They can be used instead of the specific accessor methods described above to get any non-parameterized attribute value using its NSAccessibility informal protocol constant, its accessibility API string constant cast to NSString*, or the attribute string itself. You must always use these two generic methods when you don't know which attribute you need, for example, when iterating over a list of attributes, and when a specific attribute accessor method is not implemented here. The -valueForAttribute: method automatically sends the appropriate specific attribute accessor method, if one exists for the attribute, and returns an object of the appropriate type. It even returns the value of a non-parameterized attribute that is not covered by a specific accessor method, including attributes added to the accessibility API in the future or implemented in another application like the Finder or Safari, because the framework implements the Cocoa key-value coding fallback methods using whatever attribute strings you provide. This method also returns the parameterized attribute strings if the receiver is a text area or a text field. However, you cannot obtain or set the value of parameterized attributes using key-value coding in this version of the framework. For these, you must use the specific parameterized attribute accessor methods. A few applications may not expose the AXChildren attribute in the list of attributes for some custom elements, even though these applications may in fact support the AXChildren attribute. The accessibility API may not expose the AXChildren attribute on behalf of these applications, as it used to do. Pursuant to Apple's recommendation, this method therefore always includes the AXChildren attribute in the list for all UI elements. The PFAssistive framework will always return a value for this attribute for elements that support them. See also -nonParameterizedAttributes and -parameterizedAttributes. attributesForRole:andSubrole:Class method returns an NSArray of NSDictionary objects containing information about all accessibility attributes that may or should be supported by a UI element with the specified role and subrole. + (NSArray<NSDictionary *> *)attributesForRole:(NSString *)role andSubrole:(nullable NSString *)subrole; Parameters
Return ValueAn array of NSDictionary objects, or an empty array if a UI element with the specified role and subrole should not support any attributes. DiscussionThis class method returns an array of dictionaries containing the technical names and other features of all of the accessibility attributes that a UI element with the specified role and subrole may or should support. In addition to the technical name of the attribute and the associated role, a dictionary item discloses whether the attribute is required, whether it may or should be settable, and the data types of the values in the returned array. This is general information obtained from the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist. It reads information from the role_attributes array and the attributes dictionary in the plist file. It does not guarantee that any particular UI element does in fact support the listed attributes. Each dictionary returned in the array has keys "attribute" (NSString, technical name of the attribute), "required" (NSNumber with BOOL value, NO if attribute is optional or YES if attribute is required), "role" (NSString), "settable" (NSString, "NO" if attribute must not be settable, "YES" if attribute may optionally be settable, or "REQUIRED" if attribute must be settable), and "types" (NSArray of NSStrings). The "required" field may be omitted if the attribute is not required. As of OS X Mavericks 10.9, the attributes and role_attributes arrays are believed to have been fully validated by Apple and are complete. However, Apple does not appear to be updating the AccessibilityDefinitions.plist file since then. childrenCountReturns the number of children the receiver contains. - (NSUInteger)childrenCount; Return ValueAn integer counting the receiver's children. DiscussionThis method returns the number of PFUIElement objects in the receiver's children array attribute value, or 0 if it has no children. See also -countForAttribute:. clippedRectReturns an NSRect structure representing the origin and size of the portion of the receiver that is visible in its container. - (NSRect)clippedRect; Return ValueAn NSRect structure representing the intersection of the element's visible rectangle and the rectangle of its smallest ancestor. DiscussionReturns an NSRect representing the intersection of the element's rectangle visible on the screen and the rectangle of its smallest ancestor. If the two rectangles don't overlap, the returned rectangle has its origin at {0.0, 0.0} and a size of {0.0, 0.0}. This method is useful because some elements are sized larger than their containing elements, such as a text view in a scroll view. Use the result to determine what part of the receiver, if any, is currently scrolled into view. A drawer is treated as an independent element because its parent window occupies a different screen position. countForAttribute:Returns the number of items in the specified attribute of the receiver if the attribute is an array. - (NSUInteger)countForAttribute:(NSString *)attribute; ParametersReturn ValueAn integer counting the receiver's attributes. DiscussionReturns the number of items in the specified attribute of the receiver if the attribute is an array, or 0 if attribute is not an array, doesn't exist, or has no value. A return value of 0 can therefore represent either an empty array or an error. See also -childrenCount. delegateReturns the receiver's delegate. - (nullable id <PFUIElementDelegate>)delegate; Return ValueThe receiver's delegate, an object of any type, or Discussion-PFUIElementWasDestroyed: and -PFUIElementReportError: are the only available delegate methods, which are optional. They are declared in the PFUIElementDelegate protocol. See also -setDelegate:. descriptionReturns a string describing the receiver. - (NSString *)description; Return ValueAn NSString object. DiscussionThe returned string is formatted as a property list showing the values for the receiver's AXDescription, AXHelp, AXRole, AXRoleDescription and AXSubrole attributes. In client code, call NSLog and pass in the element to see this information in the Xcode run log and debug console log. descriptionForAction:Returns a localized string describing - (nullable NSString *)descriptionForAction:(NSString *)action; ParametersReturn ValueAn NSString object, or DiscussionThese action descriptions are provided by Apple's accessibility API. It is possible for a target application to return an empty description string (as does the AXOpen action in Finder 10.3 and newer). It is up to the client to deal with this, perhaps by supplying a localizable string in a strings file in its bundle or by substituting the technical action name. descriptionForAttribute:Returns a localized string describing - (NSString *)descriptionForAttribute:(NSString *)attribute; ParametersReturn ValueAn NSString object, an empty string if the receiver does not implement DiscussionThese attribute descriptions are unique to the PFAssistive framework; Apple's accessibility API has no equivalent. The key-value pairs are defined in the PFAttributeDescriptions.strings file in the PFAssistive framework bundle. It may be possible for a target application to return an empty description string. It is up to the client to deal with this, perhaps by supplying a localizable string in a strings file in its bundle or by substituting the technical attribute name. descriptionForNotification:Class method returns a localized string describing + (NSString *)descriptionForNotification:(NSString *)notification; ParametersReturn ValueAn NSString object. DiscussionThese notification descriptions are unique to the PFAssistive framework; Apple's accessibility API has no equivalent. The key-value pairs are defined in the PFNotificationDescriptions.strings file in the PFAssistive framework bundle. It may be possible for a target application to return an empty description string. It is up to the client to deal with this, perhaps by supplying a localizable string in a strings file in its bundle or by substituting the technical notification name. descriptionForSubrole:Returns a localized string describing - (NSString *)descriptionForSubrole:(NSString *)subrole; ParametersReturn ValueAn NSString object, an empty string if the receiver does not implement DiscussionThese attribute descriptions are unique to the PFAssistive framework; Apple's accessibility API has no equivalent. The key-value pairs are defined in the PFSubroleDescriptions.strings file in the PFAssistive framework bundle. It may be possible for a target application to return an empty description string. It is up to the client to deal with this, perhaps by supplying a localizable string in a strings file in its bundle or by substituting the technical subrole name. descriptionOfTypeForAttribute:Returns a localized string describing the data type of - (nullable NSString *)descriptionOfTypeForAttribute:(NSString *)attribute; ParametersReturn ValueAn NSString object, an empty string if the receiver does not implement DiscussionThese type descriptions are unique to the PFAssistive framework; Apple's accessibility API has no equivalent. The key-value pairs are defined in the PFTypeDescriptions.strings file in the PFAssistive framework bundle. This method returns a string for the structured types point, size, rect, and range when appropriate. It may return a string for an unknown type or In the case of non-parameterized attributes, this method gets the attribute's value first and then determines the type of the attribute. For a non-localized string identifying the data type of elementAtPoint:withDelegate:error:Class method creates and returns a PFUIElement object representing the visible UI element located at + (nullable instancetype)elementAtPoint:(NSPoint)point withDelegate:(nullable id)delegate error:(NSError **)error; Parameters
Return ValueThe PFUIElement object at DiscussionUse this method to read the screen based on the current location of the mouse in top-left relative screen coordinates, or any other point of interest. This method can be the foundation of any screen reader application. In Cocoa, the mouse location can be obtained at any time in bottom-left relative screen coordinates, regardless of the current event or pending events, using NSEvent's Get the root application element that owns the returned UI element by sending -applicationElement to it. Navigate the accessibility containment hierarchy in either direction using -AXParent and -AXChildren. Use the PFApplicationUIElement instance method -elementAtPoint: instead of this class method to get a PFUIElement object representing the UI element visible at See -initWithElementRef:delegate: for important information regarding the creation of UI element objects. elementInfoReturns information about the receiver that was cached when the receiver was created, and that may have been modified later. - (nullable NSDictionary *)elementInfo; Return ValueAn NSDictionary object using NSString constants from the NSAccessibility informal protocol as keys. May be DiscussionWhen the UI element represented by the receiver is destroyed, the receiver can no longer be queried by the accessibility API for valid data about it (except for its process identification number, or PID). Any information about it that must survive its destruction therefore has to be cached when it is created. See -elementRef for information regarding destroyed UI elements. The role and, if available, the subrole, role description and title of the receiver are automatically cached when a new PFUIElement or PFAppplicationUIElement object is created. Note that the title may have changed by the time the UI element is destroyed. To make the cached title useful, a client application can update the cache at any time by sending -setElementInfo: with an appropriate dictionary entry. To retrieve these values from the dictionary returned by this method, or to set them, use as keys the NSAccessibility informal protocol string constants If the client has registered to observe the root application element or the receiver for accessibility notifications, the client's callback method will always receive the affected element, even when observing This method will return valid information about a destroyed element that was cached when the receiver was created, as described above, with one exception: If the observed element differs from the affected element (typically, when observing the root application element), this method will return If you added key-value pairs of your own to the dictionary, you can retrieve the information from the dictionary returned by this method using the keys you added. See also -setElementInfo:. elementRefReturns the accessibility API AXUIElementRef opaque object that was associated with the receiver when the receiver was created. - (nullable AXUIElementRef)elementRef; Return ValueAn opaque accessibility API object representing a UI element in the target application. The object is returned CFRetained and will be CFReleased when the PFUIElement object with which it is associated is deallocated. Do not CFRelease it yourself unless you CFRetain it yourself. May be DiscussionThe AXUIElementRef object returned by this method can be used with accessibility API functions, passed to the -initWithElementRef:delegate: method to create another PFUIElement object representing the same UI element, or passed to the -setElementRef: method for a PFUIElement object that was initialized with a The returned AXUIElementRef object may represent a UI element that no longer exists in the running application. In that case, you should not call any accessibility API function on it except to get its process identification number (PID) or to test it for equality with another AXUIElementRef ofject. It can always be used to test cached AXUIElementRef objects using You should CFRetain the returned object if you want to ensure that it persists while you are using it even after the UI element represented by the receiver is destroyed. If you do CFRetain it, CFRelease it when you are done with it. An AXUIElementRef object returned by this method is already CFRetained once, but it will be CFReleased by the framework when the PFUIElement object with which it is associated is deallocated. See also -setElementRef:. elementsWithRole:inArray:Class method returns all PFUIElement objects having attribute + (NSArray<__kindof PFUIElement *> *)elementsWithRole:(NSString *)role inArray:(NSArray<__kindof PFUIElement *> *)array; ParametersReturn ValueAn array of PFUIElement objects with attribute DiscussionUse this method to return, for example, all of an element's children that are buttons. This method does a flat search in See also +firstElementWithRole:inArray:. existsReturns whether the UI element represented by the receiver still exists in the running application. - (BOOL)exists; DiscussionReturns This method is important because the AXUIElementRef object associated with the receiver may be invalid if the UI element it represents has been destroyed; that is, if it no longer exists in the running application. A UI element can be destroyed under many circumstances, not all of them obvious. The accessibility API defines existence in terms of an element's availability in the user interface, rather than its programmatic availability. For example, a window UI element is destroyed when its application is hidden, even if the window object still exists in memory. To be prudent, you should not call any accessibility API function on a UI element that might have been destroyed without first sending it this message. You can, however, always safely get a destroyed UI element's -pid, and you can always test destroyed PFUIElement objects for equality using Due to the design of the accessibility API, some UI elements do not issue A client can observe when a UI element is destroyed by calling -setDelegate: to set itself as PFUIElement's delegate and implementing the -PFUIElementWasDestroyed: delegate method, or by registering with NSNotificationCenter to observe For other issues relating to UI elements that have been destroyed, see the -PFUIElementWasDestroyed: delegate method. See also -isDestroyed , which is the antonym of existsAction:Returns whether the receiver still exists in the running application and can perform - (BOOL)existsAction:(NSString *)action; ParametersDiscussionReturns Use this method to test, for example, whether a button element exists and supports the AXPress action. existsAttribute:Returns whether the UI element represented by the receiver still exists in the running application and recognizes - (BOOL)existsAttribute:(NSString *)attribute; ParametersDiscussionReturns Use this method to test, for example, whether a button UI element has a subrole attribute and might therefore be a close, minimize, or zoom button. Note that some UIElements have attributes with NULL values, such as 0, or an empty string. See also -existsNonParamterizedAttribute:, -existsParameterizedAttribute:, and -existsValueForAttribute:. existsNonParameterizedAttribute:Returns whether the UI element represented by the receiver still exists in the running application and recognizes - (BOOL)existsNonParameterizedAttribute:(NSString *)attribute; ParametersDiscussionReturns See also -existsAttribute:, -existsParameterizedAttribute:, and -existsValueForAttribute:. existsParameterizedAttribute:Returns whether the UI element represented by the receiver still exists in the running application and recognizes - (BOOL)existsParameterizedAttribute:(NSString *)attribute; ParametersDiscussionReturns See also -existsAttribute:, -existsNonParameterizedAttribute:, and -existsValueForAttribute:. existsValueForAttribute:Returns whether the UI element represented by the receiver still exists in the running application, recognizes - (BOOL)existsValueForAttribute:(NSString *)attribute; ParametersDiscussionReturns A value such as firstElementWithRole:inArray:Class method returns the first PFUIElement object with attribute + (nullable instancetype)firstElementWithRole:(NSString *)role inArray:(NSArray<__kindof PFUIElement *> *)array; ParametersReturn ValueThe first PFUIElement object with attribute DiscussionUse this method to test whether, for example, an application's children include any windows or a window's children include any scroll areas. This method does a flat search in See also +elementsWithRole:inArray:. indexAmongLikeElementsInArray:Returns the index of the receiver among all UI elements in - (NSUInteger)indexAmongLikeElementsInArray:(NSArray<__kindof PFUIElement *> *)array; ParametersReturn ValueThe receiver's index among like elements in DiscussionThis method does a flat search in The returned index is zero-based. For AppleScript GUI Scripting compatibility, add 1 to the index returned by this method because AppleScript indexes are one-based. UI elements whose role is "AXUnknown" should not be indexed with this method, but instead with NSArray's The indexes of windows represent their front-to-back ordering. indexPathReturns an NSIndexPath object reflecting the accessibility hierarchy of UI elements from the root application element to and including the receiver. - (nullable NSIndexPath *)indexPath; Return ValueAn NSIndexPath object starting with 0, the index of the root PFApplicationUIElement object. Returns an empty NSIndexPath object with length of 0 if the receiver has been destroyed in the running application. DiscussionThe returned index path represents the path from the root application element to and including the receiver in the target application's UI element containment hierarchy. Use -parentIndexPath to obtain an index path that excludes the receiver. If the receiver has been destroyed in the running application, the returned index path is empty. The root application element's index defaults to 0 because there is only one root application element in an application. For clients that wish to use index paths for combined management of multiple applications, the Any index in the returned indexPath object may be NSNotFound. This usually indicates a mismatch error in the target application's accessibility hierarchy, where an element is not a child of its own parent. For this reason, when using an indexPath returned by this method to obtain the element it represents, it is essential to test for out-of-range errors. This is done, for example, in -[PFApplicationUIElement elementAtIndexPath:]. Use the PFApplicationUIElement method -elementAtIndexPath: to obtain the PFUIElement object at the generated index path. initWithElementRef:delegate:Initializes and returns a newly allocated PFUIElement object. - (nullable instancetype)initWithElementRef:(nullable AXUIElementRef)uiElementRef delegate:(nullable id)aDelegate NS_DESIGNATED_INITIALIZER; Parameters
Return ValueAn initialized PFUIElement or PFApplicationUIElement object, or DiscussionThis is the designated initializer for the PFUIElement class. Use it to initialize a newly-allocated PFUIElement object with The The object passed in the Although this is the designated initializer for the PFUIElement class, a client application normally creates and initializes a new PFUIElement object in one of the four ways listed here, instead of allocating a new PFUIElement object and sending it the
This method is nevertheless handy when you need to create a temporary UI element object; for example, an object representing a known UI element in order to test it for equality with a cached element using -isEqualToElement:. You can allocate as many UI elements as you like in this way, as often as you like, and initialize each of them with This method may return a PFApplicationUIElement object, substituting it for the PFUIElement object that was initially allocated. You must therefore always follow the convention of allocating and initializing a UI element object in a single statement in this form: All PFUIElement objects except a PFApplicationUIElement object use internal mechanisms to learn when they are destroyed in the target application's user interface (for example, when a window closes), even if the client application does not register to observe Clients may subclass PFUIElement for applications that also subclass PFApplicationUIElement, by registering the PFUIElement subclass for the application's PID using the methods described in the discussion of PFApplicationUIElement subclassing. Subclasses of PFUIElement must override its designated initializer or provide a new initializer that calls its designated initializer. IMPORTANT: if you use invalidateInvalidates this PFUIElement object when it is no longer needed. - (void)invalidate; DiscussionOptionally call this method when the client application is finished with this PFUIElement object. It is desirable to call this method to avoid adding time-consuming activity at dealloc time. If the client application does not call this method, it is called automatically when the object is deallocated. It sets any delegate to Invalidation is not related to -exists or -isDestroyed , which report the existence or nonexistence of the underlying UI element in the running application. Invalidation applies only to a specific instance of PFUIElement. PFUIElement objects representing destroyed and nonexistent elements can still be used for equality tests and the like, but invalidated PFUIElement objects cannot. NOTE: PFAssistive Framework does not support garbage collected clients. See also -isValid. isAccessEnabledClass method reports whether global access for assistive devices is enabled. DEPRECATED in OS X Mavericks 10.9. + (BOOL)isAccessEnabled; DiscussionThis method is deprecated in OS X Mavericks 10.9 and newer because Apple has deprecated the function on which it relies, In OS X Mountain Lion 10.8 and earlier, returns In OS X Mountain Lion 10.8 and earlier, global access for assistive devices is enabled manually in the Accessibility (or Universal Access) pane of System Preferences. It can also be enabled programmatically using AppleScript by setting the Global access for assistive devices is turned off by default in OS X Mountain Lion 10.8 or earlier, and client applications therefore cannot use the methods of the PFAssistive framework unless they arrange to turn it on. Assistive applications commonly instruct the user to turn access on manually in System Preferences. One technique is to send the - (IBAction)enableAccessAllAction:(id)sender { SystemEventsApplication *systemEventsApp = [SBApplication applicationWithBundleIdentifier:@"com.apple.systemevents"]; if ([systemEventsApp isRunning]) { [systemEventsApp activate]; // so authentication dialog opens frontmost [systemEventsApp setUIElementsEnabled:[PFUIElement isAccessEnabled] ? NO : YES]; } [sender setState:[PFUIElement isAccessEnabled] ? NSOnState : NSOffState]; } The most sophisticated technique is to ask the user to make the assistive application alone "trusted." This is complicated for the developer in OS X Mountain Lion 10.8 or earlier because it requires an embedded helper application with root privileges and an embedded helper application to relaunch the application. It is much easier in OS X Mavericks 10.9 or later, where it requires no helper applications. See +isProcessTrustedWithOptions: for information about making a apecific client application trusted in Mavericks. Now that global access for assistive devices has been eliminated in OS X Mavericks 10.9, the meaning of the System Events See also +isAccessImplemented, +isProcessTrusted and +isProcessTrustedWithOptions:. isAccessImplementedClass method reports whether the accessibility API is implemented on this computer. + (BOOL)isAccessImplemented; DiscussionReturns See also +isAccessEnabled, +isProcessTrusted and +isProcessTrustedWithOptions:. isDestroyedReturns whether the element has been destroyed. - (BOOL)isDestroyed; DiscussionReturns See also -exists , which is the antonym of isEqualToElement:Returns whether - (BOOL)isEqualToElement:(PFUIElement *)element; ParametersDiscussionReturns This method tests whether two PFUIElement objects represent the same UI element in the running application. This works even if the UI elements represented by either or both elements no longer exist in the running application. Use this method for efficiency if you know that element is a PFUIElement or PFApplicationUIElement object. Otherwise, use isParameterizedAttribute:Returns whether - (BOOL)isParameterizedAttribute:(NSString *)attribute; ParametersDiscussionReturns If isProcessTrustedClass method reports whether the client application's process is trusted. + (BOOL)isProcessTrusted; DiscussionA "trusted" process is an application that has been granted access to the computer to monitor or control other applications using the accessibility features of macOS. It is known as an "asssistive" application, especially if it is designed to facilitate the use of the computer by persons with disabilities. An application is untrusted by default, and a client application cannot use the accessibility methods of the PFAssistive framework until the user grants access to make it a trusted process. Access is typically granted to an assistive application when it is first run or when its accessibility features are first needed. User authentication is required. See +isProcessTrustedWithOptions: for details about making a process trusted and testing its status. This method returns See also +isAccessImplemented, +isAccessEnabled and +isProcessTrustedWithOptions:. isProcessTrustedWithOptions:Class method reports whether the client application's process is trusted, optionally presenting an alert allowing the user to grant or deny access if it is not already trusted. Introduced in OS X Mavericks 10.9. + (BOOL)isProcessTrustedWithOptions:(nullable NSDictionary *)options; ParametersDiscussionA "trusted" process is an application that has been granted access to the computer to monitor or control other applications using the accessibility features of macOS. It is known as an "asssistive" application, especially if it is designed to facilitate the use of the computer by persons with disabilities. An application is untrusted by default, and a client application cannot use the accessibility methods of the PFAssistive framework until the user grants access to make it a trusted process. Access is typically granted to an assistive application when it is first run or when its accessibility features are first needed. User authentication is required. Until OS X Mavericks 10.9, a user could grant access to all assistive applications at once on a global basis instead of relying on a per-application trust mechanism. Global access was granted manually by selecting the "Enable access for assistive devices" setting in the Accessibility (or, formerly, Universal Access) pane of System Preferences. Global access could also be granted programmatically using AppleScript by setting to Per-application access was introduced by Apple in Mac OS X 10.4 (Tiger) to move away from the global on/off model, which was judged to be too broad and insecure. Initially, assistive applications could be made trusted on a per-application basis only programmatically by calling the In Mavericks, making an assistive application trusted requires a user to add the application to the new Accessibility list in the Security & Privacy preference's Privacy pane in System Preferences and select the application's checkbox. The application can be added to the list manually by dropping its application icon into the list after authenticating to unlock the preference pane, and the application's checkbox is selected to make it trusted. The application can be added to the list programmatically by calling this Either of the following statements can be used to create the options dictionary to be passed in as the parameter to this method. Passing in the first dictionary adds the application to the Accessibility list and presents the built-in system alert. Passing in NSDictionary *withAlertOption = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:(NSString *)kAXTrustedCheckOptionPrompt]; NSDictionary *withoutAlertOption = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kAXTrustedCheckOptionPrompt]; This method enables an application to determine whether it is trusted using the new Security & Privacy preference mechanism. It returns An assistive application can register to observe the "com.apple.accessibility.api" distributed notification posted by System Preferences to learn when the user grants or denies access. This notification is especially helpful when using the optional alert presented by this method, because the alert provides no way to learn which button the user clicked or what happened after the user clicked the Open System Preferences button. A suggested pattern for responding to the notification is to do it in two stages. First capture the application's old or "before" accessibility status in -applicationDidFinishLaunching:, and then in the next iteration of the run loop after the notification is received compare it to the application's new accessibility status. If the status has changed, then it is the assistive application's accessibility status that the user altered. This technique is necessary because the "com.apple.accessibility.api" notification is posted for every change in the Accessibility list, and its If this method is called under OS X Mountain Lion 10.8 or earlier, it ignores the options parameter and returns YES if the process is trusted or if global access is enabled, because before Mavericks either setting allows the client application to monitor or control other applications using accessibility features. If called in Mountain Lion or older, it should not be used to distinguish between global access and per-application trust; instead, call +isAccessEnabled or +isProcessTrusted to test those settings separately. See also +isAccessImplemented , +isAccessEnabled and +isProcessTrusted. isRole:Returns whether the receiver represents a UI element whose AXRole attribute is - (BOOL)isRole:(NSString *)role; ParametersDiscussionReturns This method tests whether the receiver's role string is equal to the string provided in the isSettableAttribute:Returns whether - (BOOL)isSettableAttribute:(NSString *)attribute; ParametersDiscussionReturns This method tests whether isSiblingOfElement:Returns whether - (BOOL)isSiblingOfElement:(PFUIElement *)element; ParametersDiscussionReturns This method works even if the UI elements represented by either or both elements no longer exist in the running application. Two root application objects are never considered siblings. isValidReports whether this PFUIElement object has been initialized and has not been invalidated. - (BOOL)isValid; DiscussionReturns See also -invalidate. isVisibleAtPoint:Returns whether the UI element represented by the receiver is visible at - (BOOL)isVisibleAtPoint:(NSPoint)point; ParametersDiscussionReturns If the UI element represented by the receiver is not visible at See +elementAtPoint:withDelegate:error: for information about how to obtain the mouse pointer's current position on the screen. nonParameterizedAttributesReturns the technical, non-localized names of all non-parameterized attributes recognized by the receiver. - (NSArray<NSString *> *)nonParameterizedAttributes; Return ValueAn array of NSString objects, or an empty array if the receiver does not recognize any non-parameterized attributes. DiscussionAll elements should return at least one non-parameterized attribute, AXRole. However, if the receiver does not support the accessibility API, this method returns an empty array. See also -attributes and -parameterizedAttributes. notificationDefinitionsClass method returns an NSDictionary object containing information about all accessibility notifications. + (NSDictionary *)notificationDefinitions; Return ValueA dictionary containing information about all accessibility notifications. DiscussionThis class method returns a dictionary containing the technical names and other features of all accessibility notifications as listed in the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist starting with Mac OS X 10.7 (Lion). It reads information from the notifications dictionary in the plist file. notificationsReturns the technical, non-localized names of all notifications issued by the receiver. - (NSArray<NSString *> *)notifications; Return ValueAn NSArray of NSString objects. All UI elements issue some notifications. DiscussionThe accessibility API does not include a function to return the notifications issued by a UI element, so the list returned by this method is arbitrary and is only as current as the version of macOS existing when this framework was last updated. The notifications returned by this method are based on the class of the receiver. The root application element reports all notifications that may be issued by any element in the application. Other elements report all notifications that might be appropriate to the nature and function of that element. Notifications returned by this method should be considered candidates until a particular application is tested. The only notifications that this method excludes are those that are plainly inappropriate for a particular element, such as menu notifications in the case of a window element, and window notififications in the case of a menu or menu item element. Note that, as of OS X Mavericks 10.9, custom UI elements that do not inherit from NSView, NSWindow or NSCell can issue notifications. The role_nofitications array in the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist still has not been fully validated by Apple and is incomplete. Apple discourages application developers from inventing new notifications, but there is no guarantee that they will not do so. The list returned by this method does not include any custom notifications implemented by third-party applications. If a client application must know of newer notifications or custom notifications implemented by other applications, it is the client's responsibility to provide them. An example of a user interface for letting users add new notifications is the Notifications pane in the Preferences window for UI Browser, an application from PFiddlesoft. The PFAssistive framework handles registration to observe notifications in the PFObserver class in PFObserver.h. In general, it is best to register to receive notifications on the root application UI element of the target application, because this guarantees that all notifications will be received from all UI elements affected by a user's activity in the user interface, even as to elements that don't yet exist at registration time. It might be sensible to register for notifications on a particular element if registering on the application element floods the client application with irrelevant notifications. Use the class method +notifications to get an array of all notifications recognized in the accessibility API. The following notifications are supported by the accessibility API (obsolete notifications are omitted):
notificationsClass method returns the technical, non-localized names of all notifications recognized by the accessibility API in the currently-running version of macOS. + (NSArray<NSString *> *)notifications; Return ValueAn array of NSString objects. DiscussionThe accessibility API does not include a function to return all available notifications, so the list returned by this method is only as current as the version of macOS existing when this framework was last updated. Use the instance method -notifications to get an array of notifications that might be issued by a specific UI element. notificationsForRole:andSubrole:Class method returns an NSArray containing the technical names of all accessibility notifications that should be supported by a UI element with the specified role and subrole. + (NSArray<NSString *> *)notificationsForRole:(NSString *)role andSubrole:(nullable NSString *)subrole; Parameters
Return ValueAn array of NSString objects, or an empty array if a UI element with the specified role and subrole should not support any notifications. DiscussionThis class method returns an array listing all of the accessibility notifications that a UI element with the specified role and subrole should support. This is general information obtained from the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist starting with Mac OS X 10.7 (Lion). It does not guarantee that any particular UI element does in fact support the notifications. As of OS X Mavericks 10.9, the role_nofitications array still has not been fully validated by Apple and is incomplete. parameterizedAttributesReturns the technical, non-localized names of all parameterized attributes recognized by the receiver. - (NSArray<NSString *> *)parameterizedAttributes; Return ValueAn array of NSString objects, or an empty array if the receiver does not recognize any parameterized attributes. DiscussionParameterized attributes exist for text areas, text fields, cell-based tables, and layout areas. If the receiver does not recognize any parameterized attributes, this method returns an empty array. See also -attributes and -nonParameterizedAttributes. parentIndexPathReturns an NSIndexPath object reflecting the accessibility hierarchy of UI elements from the root application element to the receiver's parent, but not the receiver itself. - (nullable NSIndexPath *)parentIndexPath; Return ValueAn NSIndexPath object starting with the index of the root PFApplicationUIElement object. Returns DiscussionThe returned index path represents the path from the root application element to and including the receiver's parent in the target application's UI element containment hierarchy. Use -indexPath to obtain an index path that includes the receiver itself. If the receiver has been destroyed in the running application, the returned value is nil. If the receiver is the root application element, which has no parent, the returned index path is empty. The root application element's index defaults to 0 because there is only one root application element in an application. For clients that wish to use index paths for combined management of multiple applications, the Any index in the returned indexPath object may be NSNotFound. This usually indicates a mismatch error in the target application's accessibility hierarchy, where an element is not a child of its own parent. For this reason, when using an indexPath returned by this method to obtain the element it represents, it is essential to test for out-of-range errors. This is done, for example, in -[PFApplicationUIElement elementAtIndexPath:]. Use the PFApplicationUIElement method -elementAtIndexPath: to obtain the PFUIElement object at the generated index path. parentPathReturns an array of PFUIElement objects reflecting the accessibility hierarchy of UI elements from the root application element to the receiver's parent, but not the receiver itself. - (NSArray<__kindof PFUIElement *> *)parentPath; Return ValueAn array of PFUIElement objects starting with the root PFApplicationUIElement object. The array is empty if the UI element represented by the receiver is the root application element or has been destroyed in the running application. DiscussionThe returned array represents the path from the root application element to and including the receiver's parent in the target application's UI element containment hierarchy. Use -path to obtain an array that includes the receiver itself. If the receiver is the root application element or has been destroyed in the running application, the returned array is empty. Otherwise, the first item in the array is a PFApplicationUIElement object. pathReturns an array of PFUIElement objects reflecting the accessibility hierarchy of UI elements from the root application element to and including the receiver. - (nullable NSArray<__kindof PFUIElement *> *)path; Return ValueAn array of PFUIElement objects starting with the root PFApplicationUIElement object. The result is DiscussionThe returned array represents the path from the root application element to and including the receiver in the target application's UI element containment hierarchy. Use -parentPath to obtain an array that excludes the receiver. If the receiver has been destroyed in the running application, the returned array is empty or contains only the receiver, which is an orphaned PFUIElement object. Otherwise, the first item in the array is a PFApplicationUIElement object. performAction:Causes the receiver to perform - (BOOL)performAction:(NSString *)action; ParametersReturn Value
DiscussionThis method causes the receiver to perform pidReturns the BSD Unix process identification number (PID) of the application owning the receiver. - (pid_t)pid; Return ValueAn integer, or 0 if an error occurred. DiscussionIt is sometimes useful to know the process identification number of the application owning the receiver. For example, it can be used with a variety of Carbon functions to access information not otherwise readily available in Cocoa. 0 is never a valid PID. The PID returned by this method can be used even if the receiver has been destroyed in the running application (for example, a window has closed). See also PFApplicationUIElement's -pidNumber, which returns the PID as a Cocoa NSNumber object. roleDefinitionsClass method returns an NSDictionary object containing information about all accessibility attribute roles and subroles. + (NSDictionary *)roleDefinitions; Return ValueA dictionary containing information about all accessibility attribute roles and subroles. DiscussionThis class method returns a dictionary containing the technical names and other features of all accessibility attribute roles and subroles as listed in the AccessibilityDefinitions.plist file installed at /System/Library/Accessibility/AccessibilityDefinitions.plist starting with Mac OS X 10.7 (Lion). It reads information from the roles dictionary in the plist file. Subrole strings are in the form role:subrole. setDelegate:Sets the receiver's delegate to - (void)setDelegate:(nullable id <PFUIElementDelegate>)object; ParametersDiscussionThe delegate must adopt the PFUIElementDelegate formal protocol to receive delegate messages. The delegate methods, both of which are optional, are declared in the PFUIElementDelegate protocol. If it is implemented by the delegate, a delegate method is automatically called when the UI element represented by the receiver is destroyed in the user interface or an error is reported. The delegate must adopt the PFUIElementDelegate formal protocol to receive delegate messages. The only available delegate messages are -PFUIElementWasDestroyed: and -PFUIElementReportError:, which are optional. If the delegate implements the See the -PFUIElementWasDestroyed: delegate method for important information about detecting when a UI element is destroyed in the running application's user interface. See also -delegate. setElementInfo:Caches information about the receiver. - (void)setElementInfo:(nullable NSDictionary *)info; ParametersDiscussionSee -elementInfo for details regarding the information that is cached. This message is sent automatically when a new PFUIElement or PFApplicationUIElement object is created. You can send it again if, for example, you want to update the receiver's cached title when the UI element's title changes. You can add key-value pairs of your own to the dictionary before sending this method, if you want to cache additional information about the receiver. In that case, you can retrieve the information from the dictionary returned by -elementInfo using the keys you added. See also -elementInfo. setElementRef:Sets the receiver's accessibility API AXUIElementRef opaque object to - (void)setElementRef:(AXUIElementRef)ref; ParametersDiscussionUse this method to finish initializing the receiver if See -initWithElementRef:delegate: for information about how to obtain AXUIElementRef objects to use with this method. See also -elementRef. setExists:Sets whether the receiver exists in the running application to - (void)setExists:(BOOL)flag; ParametersDiscussionIf flag is passed as Due to the design of the accessibility API, some UI elements do not issue This method enables a client to mark any UI element as destroyed in response to notification that an ancestor has been destroyed. If this technique is not adopted, a prudent client should always anticipate that a PFUIElement object it is accessing might not exist, in case -exists returns an incorrect result. There is no better way to deal with this issue; using an accessibility API function to access a destroyed UI element is not guaranteed to return an error because AXUIElementRef objects are recycled and therefore might refer to another valid UI element. IMPORTANT: If flag is passed as There should be no reason to pass flag as See also -exists. setMessagingTimeout:Sets the receiver's timeout to - (void)setMessagingTimeout:(float)timeoutInSeconds; ParametersDiscussionPass 0.0 to set the timeout to the default global timeout for the target application. If the receiver is the root application UI element, this method sets the global timeout for all UI elements in the target application. When any accessibility call fails to work within the timeout period, a kAXErrorCannotComplete error is generated. setValue:forAttribute:Sets the value of - (BOOL)setValue:(id)object forAttribute:(NSString *)attribute; ParametersReturn Value
DiscussionThis method sets the value of Use this method to set the value of a non-parameterized attribute in the general case, when you don't know which attribute you will receive. Also use this method when this framework does not include, or you prefer not to use, a specific attribute accessor method, when this framework does not implement a specific attribute accessor method, or when It is your responsibility to ensure that This method uses key-value coding to send the appropriate specific attribute accessor method, if it is implemented, falling back to a private generic method if a specific attribute accessor method is not implemented for Some applications mark attributes as settable when in fact they cannot be modified, and it is possible that this method will return See also -valueForAttribute:. typeForAttribute:Returns a non-localized string for the data type of the value of - (nullable NSString *)typeForAttribute:(NSString *)attribute; ParametersReturn ValueAn NSString object describing the data type of DiscussionReturns a non-localized string for the data type of the value of These type identifiers are unique to the PFAssistive framework; Apple's accessibility API has no equivalent. They are used for program control in the PFAssistive framework, and a client application can use them in a similar fashion, for example, as table column identifiers. According to AccessibilityDefinitions.plist, he possible strings are "array", "attributed string", "Boolean", "data", "number", "point", "range", "rect", "size", "string", "UIElement" and "URL". It appears that "date" is also a possible value. This method returns "unknown" if it cannot determine the type. This method does not return "text marker" or "text marker range" because they are marked as private in AccessibilityDefinitions.plist. This method returns a string for the structured types point, size, rect, and range when appropriate. It may return a string for an unknown type or In the case of non-parameterized attributes, this method gets the attribute's value first and then determines its type. For a localized string describing the data type of UIElementWithElementRef:delegate:Convenience class method creates and returns an initialized PFUIElement object. + (nullable instancetype)UIElementWithElementRef:(nullable AXUIElementRef)uiElementRef delegate:(nullable id)aDelegate; Parameters
Return ValueAn initialized PFUIElement object, or DiscussionUse this convenience method to create and return an initialized PFUIElement object with See the designated initializer, -initWithElementRef:delegate: for important information about creating new UI element objects. valueForAttribute:Returns the value of - (nullable id)valueForAttribute:(NSString *)attribute; ParametersReturn ValueAn object of an appropriate type, or DiscussionReturns the value of Use this method to get the value of a non-parameterized attribute in the general case, when you don't know which attribute you will receive. Also use this method when this framework does not include, or you prefer not to use, a specific attribute accessor method, when this framework does not implement a specific attribute accessor method, or when This method uses key-value coding to send the appropriate specific attribute accessor method, if it is implemented, falling back to a private generic method if a specific attribute accessor method is not implemented for The See also -setValue:forAttribute:. valueForAttribute:atIndex:Returns the value of the item at - (nullable id)valueForAttribute:(NSString *)attribute atIndex:(NSUInteger)index; ParametersReturn ValueAn object of an appropriate type, or DiscussionReturns the value of the item at Use this method to get an object at any index in the value of an array attribute. The See -typeForAttribute: for a list of recognized attribute value types. valueForAttribute:parameter:Returns the value of - (nullable id)valueForAttribute:(NSString *)attribute parameter:(id)parameter; ParametersReturn ValueAn object of an appropriate type, or DiscussionReturns the value of Use this method to get the value of a parameterized attribute in the general case, when you don't know which attribute you will receive. The See -typeForAttribute: for a list of recognized attribute value types. valuesForAttribute:range:Returns the values of - (nullable NSArray *)valuesForAttribute:(NSString *)attribute range:(NSRange)range; ParametersReturn ValueAn array of objects of any type. DiscussionReturns the values of Use this method to get multiple objects at once for the non-parameterized attributes in the Use this method instead of AXChildren when the The valuesForAttributes:Returns the values of - (nullable NSArray *)valuesForAttributes:(NSArray<NSString *> *)attributes; ParametersReturn ValueAn array of objects of any type. DiscussionReturns the values of Use this method to get multiple objects at once for the non-parameterized attributes in the The |