The various UI items can have names, but they always have indexes (their position in the list), for example the front window would be window 1.
Apple includes an Accessibility Inspector application in Xcode, or you can manually spelunk the hierarchy by using System Events to get UI elements.
GUI scripting is not for the faint of heart.
Topic:
App & System Services
SubTopic:
Automation & Scripting
Tags: