Marketcircle / AXElements

UI Automation for OS X
https://github.com/AXElements/AXElements/wiki
56 stars 14 forks source link

Unable to access controls due to QTMovie Viewer control. #73

Open Zithica opened 11 years ago

Zithica commented 11 years ago

I'm using AXElements to automate our Mac OS X desktop application. I've been able to automate all of our controls expect for one dialog. The problematic dialog has a QTMovie Viewer control. If we remove the control I can access the controls. The QTMovie Viewer control isn't modified, we're using the standard control.

The control comes up in "Accessibility Inspector" as "image" with no hierarchy. This control has a lowercase "i" and causes a "NameError: wrong constant name image" error. If I look at the main dialog the "image" control is a child of the window. I've had our developer look at the code and we can't figure out where "image" comes from.

With all of this information it appears AXElements doesn't support the QAMovie Viewer control.

The link , goes to a video depicting the problem I'm seeing and has a lot of rich information. http://www.screencast.com/t/TzVUulfX

Any help would be appreciated.

Thanks

tbartelmess commented 11 years ago

Hi,

it seems like Apple did not make QTMovieViewer properly accessible. Without proper accessibility support, AXElements won't be able to control the element.

You can try to do the work for Apple and make QTMovieViewer accessible, by replacing the methods required by the NSAccessibility protocol with your implementations, using the the Objective-C runtime.

Here is what I used for testing, to just expose the subtree of the QTKitMovieControllerView:

BOOL QT_accessibilityIsIgnored(id self, SEL selector) {
    return YES;
}

void patchQTMovieViewerAccessiblity() {
   Class movieControllerViewClass = NSClassFromString(@"QTKitMovieControllerView");
   Method m = class_getInstanceMethod(movieControllerViewClass,@selector(accessibilityIsIgnored));

   class_replaceMethod(movieControllerViewClass,@selector(accessibilityIsIgnored),(IMP)QT_accessibilityIsIgnored , method_getTypeEncoding(m));
}

the actually use this you'd have to also implement methods like accessibilityAttributeValue: to give the elements useful values.