With the release of Mac OS 10.2.3, Apple announced GUI Scripting.
GUI Scripting provides a way, using the “System Events” application, for AppleScripts to simulate manual events such as selecting popup menus, clicking buttons, and typing text. This essentially allows users to write scripts to perform tasks that they would need to manually perform in non-scriptable applications, such as print documents.
Currently, GUI Scripting is built-in into System Events under a Panther (OS X 10.3) installation.
To navigate the object hierarchy of any application, PreFab has created a tool called PreFab UI Browser, a great helper to develop scripts using Apple’s GUI Scripting technology.
Apple’s own “navigator” is called UI Element Inspector. It is not as powerful as PreFab’s application, but it is free to test, download and use!
You can also use, as alternative, the scriptable application Extra Suites from Kanzu Software for some tasks, such as simulate keystrokes, choose menu items or move and click the mouse.