【问题标题】:Applescript click 'share dropbox link' using contextual menuApplescript 使用上下文菜单单击“共享保管箱链接”
【发布时间】:2014-12-08 17:34:57
【问题描述】:

我正在尝试使用 AXShowMenu 访问特定保管箱文件夹中特定文件的上下文菜单中的“共享保管箱链接”项。

我找到了以下脚本。通过Applescript right click a file

tell application "System Events"
    tell process "Finder"
     set target_index to 1
     set target to image target_index of group 1 of scroll area 1
     tell target to perform action "AXShowMenu"
    end tell
end tell

这似乎对桌面项目有用,

但是如何使用它来定位文件夹中的特定文件,然后单击上下文菜单中的“共享保管箱链接”?

【问题讨论】:

    标签: applescript dropbox


    【解决方案1】:

    有点笨拙,但确实有效。这要求您在 Finder 中打开并位于最前面的 Dropbox 文件夹。

    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 文件夹在 Finder 中处于打开状态且位于最前面:

    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
    

    可能还有另一种选择上下文菜单的方法,但这是我在深夜喝完一杯酒后想到的。

    【讨论】:

    • 另外,在执行此操作之前,您确实应该检查 Dropbox 应用是否正在运行。
    猜你喜欢
    • 1970-01-01
    • 2011-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-11
    相关资源
    最近更新 更多