using ui scripting to get document location

According to interface inspector, there is an attribute value for a window called “Document” that lists the path to the file. Hoewever, I cannot access this value. Does anyone have any ideas on how I can access it?

Document and window attributes are defined by the application, so it all depends on which application you’re using.

For example, in BBEdit:

tell application “BBEdit”
get file of window 1
end tell

would return something like: alias: “Macintosh HD:filename.txt”

However, many applications, such as Safari, don’t have files associated with windows, so the above code would fail.

In short, you need to example the target application’s dictionary to find out what properties it supports.

I am sorry, I should have been more clear.

I am trying to use UI scripting to read the document of an open window from keynote.

set presentationPath to document of window "Presentation Tips"

The ui inspector says that there is an attribute called AXDocument that contains the path to the file. However, when I run this code it tells me that System Events got an error “NSCannotCreateScriptCommandError”.

I really need to find a way to grab the file path from keynote. ANy help would be greatly appreciated.

Ahh, you’re using Keynote, another stunning example of Apple’s inability to support AppleScript in their own applications.

Can you think of any application that would benefit from AppleScript support any more than Keynote?

I think you’re out of luck. Even using GUI scripting, you can only access UI elements. Linking a window to a disk file is beyond the UI integration.

Then may I ask why both ui browser and inspector can tell me the path to the open document? I am just trying to figure out why apples ui inspector says it is an attribute in the interface…and yet I cant access it?

So is even Keynote 1.1 unscriptable?

I need a fast way to convert text in Keynote text boxes to multiple text apptributes (this process is currently laborish at best).

Thanks,
Bill