I am reluctant to install items which I don’t have real use so I never installed the Box app and of course didn’t installed its extension Box Drive.
I just did it and the result is:
set theBundle to ((path to application "Box" as string) & "Contents:Resources:Box UI.app") as «class furl»
set copySharedLink_loc to localized string "Copy Shared Link" in bundle theBundle
set share_loc to localized string "Share" in bundle theBundle
set the clipboard to "" -- Clear the clipboard
tell application "System Events" to tell application process "Finder"
set frontmost to true
set theSelection to value of attribute "AXFocusedUIElement"
tell theSelection to perform action "AXShowMenu"
-- Now the contextual menu is revealed
tell window 1
-- class of UI elements --> {splitter group, UI element, button, button, button, toolbar, image, static text}
tell splitter group 1
class of UI elements --> {scroll area, splitter, splitter group, list}
tell splitter group 1
-- class of UI elements --> {scroll area}
tell scroll area 1
-- class of UI elements --> {outline, scroll bar, scroll bar, static text, image, static text, static text, static text, static text, static text, static text}
tell outline 1
-- class of UI elements -->{row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, row, column, column, column, column, column, column, column, group, menu}
tell menu 1
-- class of UI elements -->{menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item, menu item}
-- name of menu items --> {"Ouvrir", "Ouvrir avec", "Toujours ouvrir avec", missing value, "Placer dans la corbeille", missing value, "Afficher sur Box.com", "Déverrouiller le fichier", "Partager", missing value, "Lire les informations", "Afficher l’inspecteur", "Renommer", "Graver sur le disque…", "Dupliquer", "Dupliquer exactement", "Créer un alias", "Coup d’œil sur « Frameworks.zip »", "Diaporama « Frameworks.zip »", "Partager", missing value, "Copier « Frameworks.zip »", "Copier « Frameworks.zip » en tant que nom de chemin", missing value, "Afficher les options de présentation", missing value, "Tags…", missing value, missing value, "Send to Bear", "Search Here in BBEdit", "Open File in BBEdit"}
-- name of menu item 9 --> "Partager"
-- name of menu item 20 --> "Partager"
tell (first menu item whose name is share_loc)
click it
-- name of menu items of menu 1 --> {"Copier le lien partagé", "Envoyer un lien partagé par e-mail", "Gérer les collaborateurs"}
click menu item copySharedLink_loc of menu 1
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
set theURL to ""
repeat while (theURL = "")
try
delay 0.1
set theURL to (the clipboard as text)
end try
end repeat
theURL --> "https://app.box.com/s/q7kfpxk582r87hqw67uy4gib455jg5uj"
Select an item in the choose file dialog of Box then run the script.
Of course you may trigger it with a shortcut given with FastScripts or other dedicated tool.
The dedicated contextual menu will be revealed and the wanted item will be clicked.
Don’t change the way it triggers the menu item share_loc.
There are two items with this name, the Box’s one which is at index 9 and the Apple’s one which is at index 20. So we must explicitly trigger the first one.
As always, I left the instructions (disabled) which I used to get the infos required to reach the items to trigger.
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 22 avril 2020 14:27:52