Apple's AppleScript scripting language provides a means to obtain information from applications on a OS X system. Applications have a "dictionary" that can be consulted to determine what properties can be queried or altered. E.g., to see the dictionary for the Mail application on an OS X system, I can open the AppleScript Editor program found in
Applications/Utilities, then click on File, select Open Dictionary and scroll down until I see the Mail application listed. I can then click on it to highlight it and then click on the Choose button to open that dictionary.
[ More Info ]