Mac::Accessibility - Accessibility API perl wrappers.
AXAPIEnabled() or die "Enable access for assistive decives in System Preferneces/Universal Access" ; sub CancellDialogCallback { my ($observer, $element, $notification, $refctx) = @_ ; my $element = $app->AXUIElementCopyAttributeValue (kAXFocusedWindowAttribute); print "Title is".$element->AXUIElementCopyAttributeValue (kAXTitleAttribute)->as_string()."\n" ; $element->AXUIElementPerformAction (kAXCancelAction); }
my $app = AXUIElementCreateApplication ($pid);
my $observer = AXUIObserverCreate ($pid, CancellDialogCallback); $observer->AXObserverAddNotification ($app, kAXWindowCreatedNotification, "CancellDialog");
# Register observer to main runloop: my $runloopsource = $observer->AXObserverGetRunLoopSource(); CFRunLoopGetCurrent()->CFRunLoopAddSource($runloopsource, kCFRunLoopDefaultMode);
# Run the runllop CFRunLoopRunInMode(kCFRunLoopDefaultMode, 60.0, 1); # 1 is so that it returns immediatedly after the dialog was handled
For detailed information on the Accessibilty API (highly recommended, as a familiarity with Accessibility API is assumed in the POD), see apple.com.
http://developer.apple.com/documentation/ReleaseNotes/Accessibility/AssistiveAPI.html
The documentation is also located on your system, if you have the Developer Tools installed, at /Developer/Documentation/ReleaseNotes/.
Also of significant use are the related header files on your system: HIServices/Accessibility.h and associated files. Use the `locate` command to find them. They contain current documentation and notes for the API.
The Mac::Accessibility modules were written by Miklos Fazekas <boga@mac.com>.
Mac::CoreFoundation(1). perl(1).