开发者

How to read the content of an other app's text field on OS X?

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? :)


I would start with Applescript


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!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜