tags:

views:

49

answers:

2

Hi,

I'm very very new to OSX/UNIX and i was wondering how i would go about getting a certain text from a application window.

Explanation: App1 is running, it has a textfield with changing data. I start app2 and i want the data in the textfield from app1 available in app2. (i did not write app1 its a commercial app)

I guess it should probably be done in c++ but any other solutions are welcome.

If someone could help me in the right direction it would be much appreciated!

Thx!

+1  A: 

Your best bet is to look at the accessibility API. An accessibility client can use the descriptions and accessibility hierarchy of the views in an app to find the desired view, and then ask that view about its purpose and its content. It's the content you'll want :-).

Graham Lee
thanks, i actually found the accessibility API right after posting this question.
A: 

after some playing around i got what i needed using the following applescript:

on run argv
activate application "StupidApp"
tell application "System Events"
    tell process "StupidApp"
        get value of text field 1 of scroll area 1 of window item 1 of argv
    end tell
end tell 

end run

but this wont work if the window title has spaces in it..

so i tried with Accessibility API but i get stuck very fast! i have a AXUIElementRef for the window but how would i go about getting the value for the textfield? (the textfield has no title or discription)

Some help would be much appreciated!!