Naming

Every UI element created with an ELF command has a name. The name is necessary so that the element can be referenced after it has been created. For example the name of a control is required to query its current value or state. When using an ELF command to create a control the name is the last parameter in the command. If a name is not supplied then a unique name for the control is generated.

All ELF elements, with the exception of windows, have parents that they exist within. To avoid name conflicts with existing UI elements names need only be unique within the scope of the parent. For example in the script to create menus (shown above) each menu has a menu item named menuItem1. To distinguish between elements with the same name the full hierarchical path name of the element is used. For these menu items their full names would be ExampleWindow3|TestFileMenu|menuItem1, ExampleWindow3|TestEditMenu|menuItem1, and ExampleWindow3|TestOptionsMenu|menuItem1. With the window from Script 3 still visible, execute the following commands one at a time to query the respective labels.

menuItem -query -label ExampleWindow3|TestFileMenu|menuItem1;
menuItem -query -label ExampleWindow3|TestEditMenu|menuItem1;
menuItem -query -label ExampleWindow3|TestOptionsMenu|menuItem1;

ELF commands that create UI elements all return the full name of that element. Using the full name of an element will guarantee that you are referencing the right element. If the short name for an element is used—for example, menuItem1—there is the possibility that you will not be referencing the intended element if multiple elements with the same name exist. When using the short name ELF will first look below the current default parent for a match. If multiple matches are found then the first one is returned.