To get an idea, here a couple of (hopefully) useful topics/posts:
- UI-Scripting with AppleScript, System Events, and UI Browser
- Best Practices for GUI Scripting
- Front Window Analysis Tool Using AppleScript System Events (List UI Elements)
- OS X Accessibility Inspector (UIElementInspector) Tool for UI Scripting
- Get Reference to Menu Item
- Open All Items in Preview's "Open Recent" Menu
- UI Browser