home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-11 | 1.8 KB | 51 lines | [TEXT/ToyS] |
- set dialogResult to display dialog "Which application?" ¬
- default answer "" buttons {"Cancel", "Choose…", "OK"} default button 3
- if button returned of dialogResult = "Cancel" then error number -128
- if button returned of dialogResult = "OK" then
- set targetApplication to application (text returned of dialogResult)
- else
- set targetApplication to choose application
- end if
-
- tell targetApplication
- try
- with timeout of 30 seconds -- some applications won't respond to Menu events
- set menuListInfo to Query Menu List
- end timeout
- on error errorString number errorNumber
- if errorNumber = -126 then -- dsMBarNFnd
- error "Sorry, that program does not have a menu bar. It may be background-only." number -126
- else
- error errorString number errorNumber
- end if
- end try
- repeat with menuIndex from 1 to count of menuListInfo
- if menu title of item menuIndex of menuListInfo = "File" then
- set menuID to menu id of item menuIndex of menuListInfo
- try
- set menuInfo to Query Menu menu id menuID
- on error errorString number errorNumber
- if errorNumber = -21004 then -- nonStandardMenuErr
- error "Sorry, the File menu is a non-standard menu." number -21004
- else
- error errorString number errorNumber
- end if
- end try
- repeat with menuItemID from 1 to count of menuInfo
- set menuItemInfo to item menuItemID of menuInfo
- if menu item enabled of menuItemInfo then
- tell my application to display dialog ¬
- "File menu item “" & (menu item text of menuItemInfo) & "” is enabled!"
- end if
- if menu item text of menuItemInfo = "Quit" then
- if menu item enabled of menuItemInfo then
- Select Menu Item menu id menuID menu item id menuItemID
- else
- error "Sorry, the Quit item is disabled."
- end if
- return
- end if
- end repeat
- end if
- end repeat
- end tell