Apple's allmighty scripting language...learn more under http://www.apple.com/applescript
Take a look at all articles in this category.