Gory Details:
The tab character, in conjunction with the keystroke command from System Events, can be used to emulate the actions of a user tabbing through the fields in a UI (user interface) window. This technique can be quite useful if, for some reason, it’s not possible to select a particular field using more conventional UI commands.
Normally, when the word tab is entered in a script, it compiles as a keyword: tab. This is an AppleScript constant that represents the tab character (ASCII character 9) - similar to the other constants defined for string values: return (ASCII character 13) and space (ASCII character 32).
However, there’s a slight conflict with the word tab within a System Events tell block - where it compiles as tab group. This obviously has a different meaning, representing instead a UI element of a window.
There are several ways to avoid the difficulties that might result from this:
Firstly, we could attribute the tab constant to a variable outside the System Events tell block (as I did in my earlier script example).
Alternatively, a tab character might be entered directly as text (as demonstrated in the example above). I originally avoided this approach to minimise any confusion, since tab characters are evidently represented on these web pages as a sequence of 4 ascii characters: 32, 202, 32 & 202. (So, before attempting to run a direct copy of the above script, make sure this sequence is replaced with a genuine tab character.)
We could also use a statement such as ‘keystroke (ASCII character 9)’ - although the conversion from number to character may make this approach very slightly slower.
Finally, using raw syntax, we should even be able to force the constant to be correctly compiled within the System Events tell block:
tell application "System Events"
-- initial stuff
keystroke «constant ****tab »
-- more stuff
end tell
This should then compile as:
tell application "System Events"
-- initial stuff
keystroke tab
-- more stuff
end tell
However, there’s a downside to this method. If the script is subsequently recompiled, the statement will once more compile incorrectly (just as if the raw code had been «class tab »):
tell application "System Events"
-- initial stuff
keystroke tab group
-- more stuff
end tell
(This is all based on my personal experience, although behaviour may vary from one OS/AS version to another.) 