It seems that I misunderstood what you asked for.
As far as I know, at least in iWork components, the value of a checkbox is always the integer 0 or 1 so I don’t see the need to introduce booleans in the scheme even if I think that using the values false or true would have been more logical (testing a boolean is faster than testing the value of an integer).
As is the script is supposed to work with every localization setting.
I wished to grab the localized spelling for
“Importer” – menu item 4
“Formater” – submenu item 1
Such strings are defined in available resources but not in files dedicated to Numbers.
So I am not sure that the way they are localized match the way they are in Numbers.
For a late one
“Présentation” – menu 10 (View in English)
resources are available but I am annoyed.
I know that I added some resource files to my copy of iWork apps so I’m not sure that what I see is what would be returned on other machines.
This code would return the correct values under Mojave and Catalina but I’m not sure for High Sierra running in French.
tell application "Numbers"
set view_loc to localized string "View" from table "TSApplication"
set view295_loc to localized string "295.title" from table "MainMenu"
set view296_loc to localized string "296.title" from table "MainMenu"
end tell
{view_loc, view295_loc, view296_loc} --> {"Présentation", "Présentation", "Présentation"}
I’m sure that I added the French table “MainMenu” but I don’t remember if I did the same for “TSApplication”.
If I remember well, the numerical indexes used to point these components of a menu are unchanged since several years so I feel that we may use them “safely”.
When I face a problem requiring GUI scripting, one of my most used tool is this set of handlers :
my select_Menu("Numbers", 5, 16)
my select_SubMenu("Numbers", 10, 4, 1)
#=====
(*
useful to get the indexs of the triggered item
my select_Menu("Numbers", 5, 16) (* Insert > FileName *)
*)
on select_Menu(theApp, mt, mi)
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" -- to check that I use the correct index
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 --> "Commenter" -- to check that I use the correct index
-- click menu item mi -- disabled when the code is used to scan an item
end tell -- menu bar…
end tell
end tell -- System Events
end select_Menu
#=====
(*
useful to get the indexs of the triggered item
my select_SubMenu("Numbers", 10, 4, 3) (* Table > Footer rows > 2 *)
*)
on select_SubMenu(theApp, mt, mi, ms)
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 -- {"Tableau"} -- to check that I use the correct index
tell menu bar item mt to tell menu 1
get name of menu items --> {"Masquer la barre d’onglets", "Afficher tous les onglets", missing value, "Inspecteur", missing value, "Afficher les règles", "Guides", missing value, "Commentaires", missing value, "Masquer les activités de la collaboration", missing value, "Afficher les outils de disposition", "Afficher les couleurs", "Afficher les outils d’ajustement de l’image", "Afficher le navigateur multimédia", missing value, "Agrandir/réduire", missing value, "Afficher les avertissements", missing value, "Activer le mode plein écran", missing value, "Masquer la barre d’outils", "Personnaliser la barre d’outils…"}
get name of menu item mi --> "Inspecteur" -- to check that I use the correct index
tell menu item mi to tell menu 1
get name of menu items --> {"Formater", "Organiser", missing value, "Afficher l’onglet suivant de l’inspecteur", "Afficher l’onglet précédent de l’inspecteur", missing value, "Masquer l’inspecteur"}
get name of menu item ms --> "Formater" -- to check that I use the correct index
-- click menu item ms -- disabled when the code is used to scan an item
end tell -- menu item…
end tell -- menu bar…
end tell
end tell -- System Events
end select_SubMenu
#=====
which I use to scan the menus which must be triggered.
We can’t rely upon what we see on screen to know which is the true index of a menu item because some items may have several wording. A common case is the duo “Show something” - “Hide something”. Both appear at the same position but may have different indexes.
For other features, I scan the GUI hierarchy as you may see in the scripts which I posted here and there.
class of UI elements give the list of elements available at a given level.
In this list we see items whose properties are directly available: buttons, checkboxes …
and items containing other UI elements like sheet, table, scroll area…
With such items, we must issue a tell command then ask for the embedded UI elements.
You have some examples in the script passed in this thread (and of course in quite all my GUIScripting proposals).
I used an Apple’s tool : Accessibility Inspector.app but I never understood how to use its ‘modern’ version (5.0 or higher which is in the XCode package installed on my system has no help file available). When I am puzzled, I return to a copy of the old version 3.0 which, happily is 64bits aware.
I know that these is a third party tool available : UIBrowser (https://pfiddlesoft.com/uibrowser/) but I don’t want to pay $55.50 for a tool used to help others for free and, when I tested it I was not convinced of its interest.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 17 mars 2020 14:50:52