Parameterized attributes do not work!
I've encountered some problems with parameterized attributes. (running MacOS 12, Monterey)
The Attribute enum for parameterized values are incorrect... they shouldn't end with Parameterized.
enum Attribute {
case boundsForRangeParameterized = "AXBoundsForRangeParameterized"
// should be:
case boundsForRangeParameterized = "AXBoundsForRange"
}
Personally, I would also like the parameterized attributes to be separated into another enum.
~~I'm not sure why they're in the same enum in the first place... they're never interchangeable are they?~~
I realize it's probably for simplicity of functions like attributeIsSupported... but I'd still think it makes sense for them to be separated.
The other thing I found is that the parameterizedAttribute in UIElement doesn't work correctly.
I was trying to set AXBoundsForRange and passing in a CFRange, but it would throw an AXError.IllegalArgument error.
I figured out that it's because the param value does not use packAXValue, unlike setAttribute.
open func parameterizedAttribute<T, U>(_ attribute: String, param: U) throws -> T? {
...
let error = AXUIElementCopyParameterizedAttributeValue(
element, attribute as CFString, param as AnyObject, &value
)
// should be something like this:
let error = AXUIElementCopyParameterizedAttributeValue(
element, attribute as CFString, packAXValue(param), &value
)
...
}
I can't easily test this fully, since I can't access packAXValue in an extension (because it's fileprivate), but doing manual conversion to an AXValue seems to fix it!
I also encountered this problem.
Confirm that a6bd34f8cd30980a1e5fbf8bec41b77068f787ee and 8d8b307edeb76ef133784d8be3981824c3c5fefa can fix it.
@tisfeng Yes, those appear to fix the issue(s)!