my select_SubMenu("Preview", 4, 11, 3)
#=====
(*
useful to get the indexs of the triggered item
my select_SubMenu("Numbers", 6, 14, 3) (* Table > Footer rows > 2 *)
*)
on select_SubMenu(theApp, mt, mi, ms)
activate application theApp
tell application "System Events" to tell process theApp
set frontmost to true
tell menu bar 1
get name of menu bar items
(*{
01 - "Apple",
02 - "Aperçu",
03 - "Fichier",
04 - "Édition",
05 - "Présentation",
06 - "Aller",
07 - "Outils",
08 - "Fenêtre",
09 - "Aide"}
*)
log result
get name of menu bar item mt
-- {"Édition"}
tell menu bar item mt to tell menu 1
get name of menu items
(* {01 - "Annuler",
02 - "Rétablir",
03 - missing value,
04 - "Couper",
05 - "Copier",
06 - "Coller",
07 - "Supprimer",
08 - "Tout sélectionner",
09 - "Inverser la sélection",
10 - missing value,
11 - "Insérer",
12 - "Placer dans la corbeille",
13 - missing value,
14 - "Rechercher",
15 - "Orthographe et grammaire",
16 - "Parole",
17 - missing value,
18 - "Démarrer Dictée…",
19 - "Emoji et symboles"}
*)
set nameMi to name of menu item mi
--"Insérer"
tell menu item mi to tell menu 1
get name of menu items
(* {
1 - "Page de scanner…",
2 - "Page de fichier…",
3 - "Page vierge"}
*)
set nameMs to name of menu item ms
-- "Page de fichier…"
if enabled of menu item ms then
click menu item ms
else
error "The menu “" & nameMi & "” > “" & nameMs & "” is disabled!"
end if
end tell -- menu item…
end tell
end tell -- menu bar…
end tell -- System Events
end select_SubMenu
#=====
Yvan KOENIG running El Capitan 10.11.3 in French (VALLAURIS, France) samedi 5 mars 2016 19:18:06