有點kludgey,但它確實有效。這要求您在Finder中打開並放置保管箱文件夾。
tell application "Finder"
activate --brings Finder to front
select item 1 of window 1 --selects the first item in the list ; not sure how you want to select/determine the item
end tell
delay 0.5 --this is to insure you don't get unwanted typing in script editor (makes sure Finder activates before kludgey typing gets done)
tell application "System Events"
tell application process "Finder"
set _selection to value of attribute "AXFocusedUIElement" --focused element (selected element)
tell _selection to perform action "AXShowMenu" --contextual menu
end tell
keystroke "share dropbox link" --type to select contextual menu item
keystroke return --select it by hitting return
end tell
[編輯]這裏有一個竅門,以確保您的Dropbox文件夾是開放的,最前面的搜索工具:
tell application "Finder"
activate --brings Finder to front
tell me to set dbFolder to POSIX file ((do shell script "cd ~/Dropbox/;pwd") & "/")
open dbFolder
select item 1 of window 1 --selects the first item in the list ; not sure how you want to select/determine the item
end tell
tell application "System Events"
tell application process "Finder"
set _selection to value of attribute "AXFocusedUIElement" --focused element (selected element)
tell _selection to perform action "AXShowMenu" --contextual menu
end tell
keystroke "share dropbox link" --type to select contextual menu item
keystroke return --select it by hitting return
end tell
有可能是選擇上下文菜單中的另一種方式,但這是我在深夜喝了一杯葡萄酒後纔想到了什麼。
另外,在做這件事之前,你真的應該檢查實際正在運行的保管箱應用程序。 – CRGreen 2014-12-08 09:38:31
適合我!謝謝CRG – MonkeyCMonkeyDo 2014-12-09 03:15:35
不客氣!很高興有幫助。 – CRGreen 2014-12-09 06:50:06