In order to store an object's values for external (outside AS) access, I need to be able to get every property of that object, and then I'd try to coerce it to text and store it somehwere.
How do I get the list of properties that an object holds. As an example, I can write this:
tell me
get properties
end tell
That works for a script object.
But for many other objects, I simply get an error such as "descripter type mismatch", like here:
tell application "iTunes"
get properties of file track 1
end tell
Now, I know the excellent Script Debugger can do it (it can show any object's entire set of properties), so it should be possible in written AppleScript as well. What's the secret to this?
Mark Alldritt, the author of Script Debugger, was so kind to explain the "secret" to me.
Script Debugger uses some special AppleScript API functions, including OSAGetPropertyNames(), to get to this information.
Hence, if I write a wrapper in, for instance, C, I can probably get to this, too.
Update
The Cocoa Scripting API has a dedicated classes for this (NSScriptSuiteRegistry
and NSScriptClassDescription
) - the framework builds this information from reading an app's scripting definition (.sdef) file. With that, all the available class and their properties can be learned quite easily.