You may use this one :
set recentItems to my inspect_SubMenu(1, 9)
set whichItem to choose from list recentItems
if whichItem is false then error number -128
my selectSubMenu(1, 9, item 1 of whichItem)
--=====
on selectSubMenu(mt, mi, ms)
tell application "System Events"
set theApp to (name of first process whose frontmost is true)
tell process theApp to tell menu bar 1 to tell menu bar item mt to tell menu 1 to tell menu item mi to tell menu 1 to click menu item ms
end tell --
end selectSubMenu
--=====
on inspect_SubMenu(mt, mi)
-- tell application "Script Editor" to activate
tell application "System Events" to tell process (name of first process whose frontmost is true) to tell menu bar 1
get name of menu bar items
(*
{"Apple", "Éditeur de scripts", "Fichier", "Édition", "Présentation", "Script", "Police", "Format", "Fenêtre", "Aide"}
*)
get name of menu bar item mt
-- {"Apple"}
tell menu bar item mt to tell menu 1
get name of menu items
(*
{"À propos de ce Mac", "Mise à jour de logiciels.", "Logiciels Mac OS X.", missing value, "Préférences Système.", "Dock", "Configuration réseau", missing value, "Éléments récents", missing value, "Forcer à quitter.", "Forcer à quitter Éditeur de scripts", missing value, "Suspendre l'activité", "Redémarrer.", "Redémarrer", "Éteindre.", "Éteindre", missing value, "Fermer la session Yvan KOENIG.", "Fermer la session Yvan KOENIG"}
*)
get name of menu item mi
--"Éléments récents"
tell menu item mi to tell menu 1
set subMenuItems to get name of menu items
(*
{"Applications", "Adobe Reader.app", "Aperçu.app", "CocoThumbX.app", "ImageWell.app", "Pages 09English.app", "Pages.app", "Pages09English.app", "récupère_Chemin.app", "TextEdit.app", "Xcode.app", missing value, "Documents", " bug_reports'09.rtfd", " référence à selectSheet.rtf", "2duplicate.applescript", "2Duplicate.numbers", "2duplicate.scpt", "4gradebooks.applescript", "4gradebooks.scpt", "4tests.numbers", "2010_05_03b.jpg", "2010_05_05e.jpg", "2010_05_06j.jpg", "a_library.applescript", "add_date_formats.applescript", "columnsBySpaceAlts.applescript", "com.apple.iWork.Numbers.plist", "com.apple.iWork.Numbers.plist", "createNewTableInHistory.applescript", "DATABASE_TV.numbers", "duplicate Sheet and Table.applescript", "en_US.plist", "five_to_one_alt.applescript", "for_labels.sparseimage", "fr_FR.plist", "getdisplay.sh", "Image 1.jpg", "Image 2.jpg", "Image 3.jpg", "Image 4.jpg", "Image 5.jpg", "Image 6.jpg", "Image 7.jpg", "Image 8.jpg", "Image 9.jpg", "Image 10.jpg", "Image 11.jpg", "Image 12.jpg", "Image 13.jpg", "Image 14.jpg", "Image 15.jpg", "Image 16.jpg", "InfoPlist.strings", "liens_pour_forum.rtfd", "Localizable.strings", "Numbers.sdef", "Pages09_UserGuide.pdf", "Pages09English.dmg", "Perfect_Gradebook YK.numbers", "Perfect_Gradebook.numbers", "prepare_merge_2_labels.applescript", "selection2print_alt.applescript", missing value, "Effacer le menu"}
*)
end tell
end tell
end tell
return subMenuItems
end inspect_SubMenu
Yvan KOENIG (VALLAURIS, France) samedi 8 mai 2010 19:27:55