onmenu_click(mList)localappName,topMenu,r-- Validate our inputifmList's length<3thenerror"Menu list is not long enough"-- Set these variables for clarity and brevity later onset{appName,topMenu}to(items1through2ofmList)setrto(items3through(mList's length)ofmList)-- This overly-long line calls the menu_recurse function with-- two arguments: r, and a reference to the top-level menutellapplication"System Events"tomymenu_click_recurse(r,((processappName)'s ¬(menubar1)'s (menubaritemtopMenu)'s (menutopMenu)))endmenu_clickonmenu_click_recurse(mList,parentObject)localf,r-- `f` = first item, `r` = rest of itemssetftoitem1ofmListifmList's length>1thensetrto(items2through(mList's length)ofmList)-- either actually click the menu item, or recurse againtellapplication"System Events"ifmList's lengthis1thenclickparentObject's menuitemfelsemymenu_click_recurse(r,(parentObject's (menuitemf)'s (menuf)))endifendtellendmenu_click_recursetellapplication"iPhone Simulator"activateendtellmenu_click({"iPhone Simulator","硬件","模拟内存警告"})