NS.X. NS.X. - 1 year ago 137
AppleScript Question

Get item type and other metadata in AppleScript

In AppleScript, how can I list an object's "metadata" (or what's the right terminology in AppleScript?), and how do I get "type" metadata for an object?

In other word, how can I implement these functions:

on GetType(x)
return ??? -- returns "window" if x is a window
end GetType

on ListMetadata(x)
repeat ??? -- enumerate through "name", "(what is it for type)", etc.
end repeat
end ListMetadata

Answer Source

The first function can be accomplished with

on GetType(x)
    return class of x as text
end GetType

Metadata are properties in AppleScript, however properties are not required and the type of properties is a record (dictionary) which cannot be simply enumerated in a repeat loop.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download