Open muescha opened 2 years ago
You can definitely just use plain English as it appears in the menu itself. For example:
hs.application.get("Safari"):selectMenuItem({"Safari", "About Safari"})
sorry - that not works - and that is my problem as described in the issue
my macOS system language is german:
the call i need for my example is:
app:selectMenuItem("Tab in ein neues Fenster verschieben")
and for your example i need:
hs.application.get("Safari"):selectMenuItem({"Safari", "Über Safari"})
Please double check: did you have the same german menu in your Safari and you can use the english identifiers for selectMenuItem
?
Oh, I see what you mean now - you want to share some Lua code with others, and you want it to work on any language.
This is more tricky.
One way to do it would be using "position" data instead - i.e. select menu item 1, sub-menu item 1, etc. You could use hs.axuielement
for this. Of course, the downside is that if the menu structure changes between updates, your code breaks.
Another way would be to read the MainMenu.nib
file data - but that'll require a lot of code. You can see how we do this in CommandPost here: https://github.com/CommandPost/CommandPost/blob/develop/src/extensions/cp/app/menu.lua
thats tricky - is there any debugger for nib-files available just to look into it?
You could download CommandPost and have a play with cp.nib.archiver
.
i have this problem:
Move tab to new window
)selectMenuItem
print(hs.inspect.inspect(app:getMenuItems()))
Question:
selectMenuItem
in english?EDIT: additional information: