views:

74

answers:

4

For a project I must create a little buddy app that will read the content of one of the main app's text fields.

Is there a way to get to the contents of a window/control (I'm interested in the text of the text field) on OS X? Something like GetDlgItemText() on Windows where I just pass the control's global handle and will get the control's text.

Could anyone of you give me some keywords to google for? :)

A: 

Start here.

NSResponder
+1  A: 

I would start with Applescript

Thomas
+1  A: 

The UIElementInspector sample project is a great starting point for using the Accessibility APIs.

Another good thing to google is "AppleScript Interface Scripting"

If you are using AppleScript from Cocoa on 10.5 or later, the Scripting bridge can make your life easier.

Good luck!

Vincent Gable
thanks for the sample project link. :)
Jaroslaw Szpilewski
A: 

For a project I must create a little buddy app that will read the content of one of the main app's text fields.

Forget about the text field—the companion app doesn't need to know or care about it. Have the main app pass the bit of text to the companion app, or the companion app request it from the main app. You can use Distributed Objects to do this.

Something like GetDlgItemText() on Windows where I just pass the control's global handle and will get the control's text.

There is no global handle for a control in a process in Mac OS X. The closest thing would be Accessibility, but there are much easier ways to do this that don't require access for assistive devices to be turned on. DO is one of them.

Peter Hosey