I'm sorry I couldn't come up with a better title. I've made a little applescript service that gets the unix path to a file you selected in the Finder and then stores that path in the clipboard. The files I use this for are in my Google Drive volume and now I'd like to add an extra feature which is powered by Google Drive File Stream application.
If I right click on a Google Drive file in the finder, I get 3 extra items in the context menu, see attached screenshot. All I want is my script to run "Copy link to clipboard".
So how do I tell apple script to do so? I'm sorry for the very trivial question, but I think I lack the right terminology to make a Google search, all I could find was how to add an apple script to a context menu, which I already did.

Use AXShowMenu to open the context menu. Then send the keystroke "Copy link to clipboard" to select the copy action, and send "Enter" to activate the action.
tell application "System Events" to tell application process "Finder"
set selectedFile to value of attribute "AXFocusedUIElement"
tell selectedFile to perform action "AXShowMenu"
delay 0.5
keystroke "Copy link to clipboard"
-- Sends enter
key code 36
end tell
Note that this doesn't work properly when using Finder's icon view. The list view or column view must be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With