Re: "hooking" into another app
Re: "hooking" into another app
- Subject: Re: "hooking" into another app
- From: Ricky Sharp <email@hidden>
- Date: Tue, 15 Apr 2008 17:09:39 -0500
On Apr 15, 2008, at 4:37 PM, Jens Alfke wrote:
On 14 Apr '08, at 2:39 PM, Bill Cheeseman wrote:
However, the
Accessibility API is also wonderfully useful for doing lots of
other things,
such as hooking into a text chat window so that you can log the
incoming
messages.
I'm not so enthusiastic about it … it's basically the GUI equivalent
of Application Enhancer, or of HTML screen-scraping. Just as
searching through the raw HTML of a website isn't a reliable way to
get information from the server, groping through the views of
another app isn't a reliable way to interact with it. In both cases,
there's nothing to keep the layout of the user interface from
changing in the future, and even minor changes that don't have a
visual effect could break anything that's groping inside them. (For
example, if the order of two buttons gets changed around for some
reason in a nib, something using the accessibility API to drive
those buttons is going to end up pressing the wrong one.)
That's not how accessibility works though. When an app supports it
(which most Cocoa apps do if using the Aqua UI), the visual UI
hierarchy is ultimately flattened into an accessibility hierarchy (see
various overview docs for more detail). Also, you don't access things
by absolute position, or physical order. So, if layout changes, you
can still access the required button.
Perhaps you're thinking of the specific case of GUI scripting? In
that case, you do sometimes end up with AppleScript commands that
reference things by ordinal value (e.g. button 1 of window 3).
I understand that sometimes there isn't any other way to get
something done, but IMHO using accessibility to do such things is in
the "skanky hack that just happens to work" category. In the case of
iChat it would be a lot better to use its existing AppleScript
support to add handlers for when messages are received.
I will agree that this approach would be better. After all, if
accessibility is turned off, there won't be any access to data via
those APIs. The AppleScript approach would be available no matter what.
Although, I have to say that I believe that of all apps out there,
more probably support accessibility features than do AppleScript.
Thus, YMMV.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden