Here are two simple scripts showing the steps used to get the needed code with no extraneous tool.
#=====
(*
useful to get the indexs of the triggered item
my select_Menu("Numbers", 5, 12) (* Insérer > Zone de texte *)
*)
on select_Menu(theApp, mt, mi)
activate application theApp
tell application id "com.apple.systemevents" to tell process theApp
set frontmost to true
tell menu bar 1
get name of menu bar items --> {"Apple", "Numbers", "Fichier", "Édition", "Insérer", "Tableau", "Organiser", "Format", "Disposition", "Présentation", "Partager", "Fenêtre", "Aide"}
get name of menu bar item mt --> "Insérer"
tell menu bar item mt to tell menu 1
get name of menu items --> {"Feuille", missing value, "Saut de ligne", "Saut de colonne", missing value, "Numéro de page", "Nombre de pages", "Date et heure", missing value, "Tableau", "Graphique", "Zone de texte", "Figure", "Ligne", "Surligner", "Commenter", "Galerie d’images", "Enregistrer l’audio", missing value, "Rangs copiés", "Colonnes copiées", missing value, "Formule", "Équation…", missing value, "Choisir…"}
get name of menu item mi --> {"Zone de texte"}
-- click menu item mi -- Enable it when everything is OK
end tell -- menu bar item…
end tell -- menu bar 1
end tell -- System Events
end select_Menu
#=====
(*
useful to get the indexs of the triggered item
my select_SubMenu("Numbers", 6, 6, 3) (* Disposition > Aligner les objets > à droite *)
*)
on select_SubMenu(theApp, mt, mi, ms)
activate application theApp
tell application id "com.apple.systemevents" to tell process theApp
set frontmost to true
tell menu bar 1
get name of menu bar items --> {"Apple", "Numbers", "Fichier", "Édition", "Insérer", "Tableau", "Organiser", "Format", "Disposition", "Présentation", "Partager", "Fenêtre", "Aide"}
get name of menu bar item mt --> "Disposition"
tell menu bar item mt to tell menu 1
get name of menu items --> {"Avancer d’un plan", "Placer au premier plan", "Reculer d’un plan", "Placer à l’arrière-plan", missing value, "Aligner les objets", "Répartir les objets", missing value, "Retournement horizontal", "Retournement vertical", missing value, "Verrouiller", "Déverrouiller", missing value, "Groupe", "Dissocier"}
get name of menu item mi --> "Aligner les objets"
tell menu item mi to tell menu 1
get name of menu items --> {"à gauche", "au centre", "à droite", missing value, "en haut", "au milieu", "en bas"}
get name of menu item ms --> "à droite"
set isEnabled to get enabled of menu item ms --> false
if isEnabled then
-- click menu item ms -- Enable it when everything is OK
end if
end tell -- menu item…
end tell -- menu bar item…
end tell -- menu bar 1
end tell -- System Events
end select_SubMenu
#=====
You may find numerous examples coded step by step on macScripter, searching for Keyword Search : GUI
Author Search : Yvan KOENIG