I did find out today, yep subscribed from may 2006, but never did do something actually, that f.e let mail create a new message I have to use the local language.
F.e
try
tell application "Mail"
activate
end tell
tell application "System Events"
click menu item "New Message" of menu "File" of menu bar 1 of process "Mail"
end tell
end try
doesn’t work but
try
tell application "Mail"
activate
end tell
tell application "System Events"
click menu item "Nieuw bericht" of menu "Archief" of menu bar 1 of process "Mail"
end tell
end try
works!
How do you guys and girls handle this kind of situations?
How can I check what kind of language is selected?
Is it possible to find and use the english names for the menu’s anyway?
I use Tiger.8 and it looks like I have to be trained by the wild animal
With the menu item numbers I am afraid that when Apple or the creator of the app, moves or inserts a menuitem, I come in trouble. also I notice that using the scripteditor give different results then using f.e Xcode plugin
The code above I suggesting that it was working doesn’t work in a Xcode plugin.
So I start trying how the menus are looking alike.
property tot : ""
set b to {} as list
tell application "Xcode" to activate
tell application "System Events"
set b to name of menu bar items of menu bar 1 of application process "Xcode"
end tell
repeat with a in b
set totaal to totl & " " & a
end repeat
display dialog tot
This works in scripteditor, but in Xcode I get the NSReceiverEvaluationScriptError: 4 (1) error
The failure is due that there is a menu bar item without a name: the Script one.
This one build a list of items.
set theApp to "Xcode"
tell application theApp to activate
set theMenus to ""
tell application "System Events" to tell application process theApp to tell menu bar 1
set lm to (get name of every menu bar item)
repeat with i from 1 to count of lm
set theMenus to theMenus & (lm's item i) & return
tell menu bar item i to tell menu 1 to set lni to (get name of every menu item)
repeat with nmi in lni
set theMenus to theMenus & space & nmi & return
end repeat
end repeat
end tell
At this time, there is no safe way to get the localized menu or menuItem names.
They are stored in .nib files which are not accessible to the Standard Addition tool named “localized string”.
Maybe you may post a request for a way to access these localized items to the Apple link dedicated to that kind of suggestions.
At this time I doesn’t remind of it.
Yvan KOENIG (from FRANCE vendredi 20 octobre 2006 19:14:17)
This works in ScriptEditor, but not in a Xcode plugin. Still get the same error.
The funny things , I don’t have a script menu ( with just an icon, inside Xcode if this is what you meant ). I did have in the past.
Also, I can’t see it with ui Inspector.
Do you have more suggestions? I did search, and stil searching, but is there a good article about menu items?
I never use Xcode plugins" so I am unable to test.
Perhaps in such an environment you must explicitely activate System Events.
May you try
set theApp to "Xcode"
tell application theApp to activate
set theMenus to ""
tell application "System Events"
activate
tell application process theApp
set frontmost to true
tell menu bar 1
set lm to (get name of every menu bar item)
repeat with i from 1 to count of lm
set theMenus to theMenus & (lm's item i) & return
tell menu bar item i to tell menu 1 to set lni to (get name of every menu item)
repeat with nmi in lni
set theMenus to theMenus & space & nmi & return
end repeat
end repeat
end tell
end tell
end tell
The old potter I am is tired and will switch off the mac.