help needed UI Scripting nested menu items: mail.app

hi-

i want a bit of my script to take accounts online if they are not. i cannot find any dox to do this in the mail.app dictionary. so, i’m getting close with UI scripting…but, not quite there.

the particular menu i need to choose is:
menu item “Go Online” of “Online Status” of menu “Mailbox”

however i can’t seem to come up with the right AS.

the following code works as far as the first menu.


tell application "System Events"
	tell process "Mail"
		tell menu bar 1 --menu bar
			tell menu "Mailbox"
				click menu item "Online Status"
			end tell
		end tell
	end tell
end tell

but, i have trouble getting the nested menu to click.

i’ve tried


tell application "System Events"
	tell process "Mail"
		tell menu bar 1 --menu bar
			tell menu "Mailbox"
				tell menu item "Online Status"
					click menu item "Go Online"
				end tell
			end tell
		end tell
	end tell
end tell

and


click menu item "Go Online" of menu "Online Status" of menu item "Online Status" of menu "Mailbox" of menu bar 1 of process "Mail"

(which is a direct ripoff of the sample UI script that chooses the ‘Automatic’ location)


click menu item "Automatic" of menu "Location" of menu item "Location" of menu "Apple" of menu bar 1 of process "Finder"

any suggestions? thx.

for future reference, i found the answer right on apple’s own UI scripting page :rolleyes:

this has only been nagging me for 1/2 a week now :oops: