An assistive application can easily get the value of a target application's parameterized attribute if the attribute is one of the standard attributes, because the type of the required parameter is publicly documented (though sometimes only in vague English instead of by formal type). For example, the standard AXCellForColumnAndRow attribute is documented to take a parameter that is an NSArray containing two NSNumbers or their Core Foundation equivalents. See the NSObject(NSAccessibility) reference document.
But how can an assistive application programmatically obtain the value of custom parameterized attributes implemented by other applications, in the general case? It is necessary to provide a parameter of the correct type when calling AXUIElementCopyParameterizedAttributeValue(). I can get the custom attribute names by calling AXUIElementCopyParameterizedAttributeNames, but the name of the attribute is not a clearcut way to ascertain the expected parameter type, especially programmatically.
Even for the standard parameterized attributes, it would be nice to be able to write an assistive application to create parameters by type generally, instead of having to use a list of known parameterized attributes and their documented types and code separately for each attribute. Only some applications document their custom accessibility attributes, anyway, such as WebKit for Safari.
I am familiar with CFTypeID and CFGetTypeID, but they are only useful if I already have a parameter to examine. For example, I can call AXValueForAttribute() with the AXInsertionPointLineNumber attribute to get a CFTypeRef reference with an appropriate CFTypeID specifying the line number of the target application's insertion point, then I can pass the line number to AXUIElementCopyParameterizedAttributeValue() with the AXRangeForLine parameterized attribute. And I can do the same with equivalent methods in other applications using custom attributes, if they are documented.
But these techniques don't help me learn the required parameter type for more general use when all I have is the name of a custom parameterized attribute that I want to use. Specifically, I am updating my UI Browser product, and I want to be able to report to my users the type of the required parameters for every target application that my users might have installed on their computer, now and in the future. Currently, UI Browser can only do that with the standard parameterized attributes.
If there is an answer, I am particularly interested in doing this in Swift. |