Re: "hooking" into another app
Re: "hooking" into another app
- Subject: Re: "hooking" into another app
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 14 Apr 2008 17:39:36 -0400
- Thread-topic: "hooking" into another app
on 2008-04-14 8:30 AM, Don Arnel at email@hidden wrote:
> I am attempting to write a Cocoa app that I would
> like to have "hook" into a text chat window from another app so that I
> can log the incoming messages. The other app does not belong to my app.
>
> If anyone could point me to some help topics on how this can be
> accomplished I would greatly appreciate it.
Use the Accessibility API. It's designed to do exactly this. It's a C API,
not Cocoa or Objective-C, but you can use it in a Cocoa application.
The Accessibility API does two things: (1) it enables you to make the user
controls and views in your application accessible to so-called "assistive
applications," and (2) it enables you to write an "assistive application"
yourself that accesses the user controls and views of any application. The
Accessibility API was created to make applications accessible to people with
disabilities through assistive devices and applications. 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.
Apple has lots of documentation about how to make your own application's
user controls and views accessible by assistive applications, but that
usually is only necessary if your application has custom user controls and
views. If your application uses standard Carbon or Cocoa code for its user
controls and views, they are automatically accessible out of the box.
But Apple offers very little documentation about how to write an assistive
application, which is what you want to do. There is a reference document
that describes the functions in the Accessibility API that you have to use
to write an assistive application, and there are a couple of example code
projects, including the UI Element Inspector example.
You can download the free 30-day trial version of my PreFab UI Browser at
<http://prefabsoftware.com/uibrowser/>, which uses the Accessibility API to
read and manipulate other applications. Try it with your target
application's chat window to see whether UI Browser is able to read the
incoming messages. You might have to read the chat window periodically to
notice new messages, but more likely your assistive application can install
(or register) a notification observer that will notice every time the
content of the chat window changes. You can test that in UI Browser, too. In
your "assistive" application, you would respond to each such notification by
reading the new content of the chat window and saving it to your log.
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
www.quecheesoftware.com
PreFab Software - www.prefabsoftware.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