
How can I toggle between check marked items on menu path.
I don't know how to describe the state that menu path is selected in scripts even though I watched the tutorial video for if/else statement...
As a side note, I use this script to click menu path on this dropbox menu.
const popupMenu = sf.ui.finder.mainWindow.children.whoseRole.is("AXToolbar").first.groups.allItems[4].children.whoseRole.is("AXMenuButton").whoseTitle.is("").first.popupMenuOpenFromElement().popupMenu;
popupMenu.menuClickPopupMenu({
menuPath: ["Copy Dropbox Link"],
});
- samuel henriques @samuel_henriques
Hello Fukurou Toshima,
The script finds where the dropbox is positioned in the tool bar. Otherwise, if for some reason the position changes the script would fail.
Then it will select the menu that is not selected. For all file/folder selected, not for each file/folder selected. If you want it for each, let me know.
Hope it works for you.
const toolsBar = sf.ui.finder.mainWindow.children.whoseRole.is("AXToolbar").first const dropboxIndex = toolsBar.groups.findIndex(g => g.children.whoseRole.is("AXStaticText").invalidate().whoseValue.is("Dropbox").exists) if (dropboxIndex >= 0) { toolsBar.groups.allItems[dropboxIndex].children.whoseRole.is("AXMenuButton").first.popupMenuSelect({ menuSelector: items => items.filter(menu => menu.path[0] === "Smart Sync" && !menu.element.isMenuChecked)[0] }); } else { log("Dropbox not found in the toolbar.") };
samuel henriques @samuel_henriques
UPDATE, simplified the script
samuel henriques @samuel_henriques
Be aware this will only work with the option Icon & Text selected:
- In reply tosamuel_henriques⬆:FFukurou Toshima @Fukurou_Toshima
Hello samuel,
Thank you so much for nice simple script. It's like a magic.
It works completely as I want it to.Do you mind if I ask which part of this script can make it know which menu item is checked and select the one that is not?
It may be not a thing I should ask here instead of studying in the tutorial web site for coding tho...samuel henriques @samuel_henriques
Hello Fukurou,
Awesome its working.
I'll try to explain:
This bit will get us all the menu and submenus from the dopbox button:toolsBar.groups.allItems[dropboxIndex].children.whoseRole.is("AXMenuButton").first.popupMenuSelect({ menuSelector: items => items });
Now we need to filter what we are looking for, in this case we want menu "Smart Sync" that's
menu.path[0] === "Smart Sync"
and&&
,
the not!
selected(checked) menu, that's!menu.element.isMenuChecked)
.filter(menu => menu.path[0] === "Smart Sync" && !menu.element.isMenuChecked)[0]
Hope this was clear.
- FFukurou Toshima @Fukurou_Toshima
Thanks for everything you did! I'll keep trying.
- In reply tosamuel_henriques⬆:FFukurou Toshima @Fukurou_Toshima
Hello Samuel,
Recently I updated my OS from Catalina to Big Sur And this script has not worked.
Of course Dropbox menu is on the toolbar.
But log says "Dropbox not found in the toolbar."I guess the name of menu items haven't changed (I tried picking UI element)
so I don't know why..
Could you make this work on Big Sur too??
I need this script so hard...Thank you for your support.