0

我们正在使用 Applescript 使用 Lightroom 5(CC 的最新版本)开发一个简单的自动化工具。

对于某些操作,我们需要智能收藏面板中的上下文菜单,例如导入智能收藏描述。

根据 stackoverflow 和其他地方的文档和各种来源,AXShowMenu 应该会显示该菜单。

到目前为止,我还无法弹出该上下文菜单。

使用 UIElementInspector 和 UI 浏览器,我找到了附加了 AXShowMenu 操作的元素。根据 UI Browser 提供的代码,我得到了以下脚本,我从 Applescript 编辑器运行:

tell application "Adobe Photoshop Lightroom 5"
    activate
    tell application "System Events"
        tell process "Lightroom"
            set frontmost to true
            perform action 1 of static text "Smart Collections" of group 1 of row 11 of outline 1 of scroll area 1 of window 6
            delay 2
        end tell
    end tell
end tell

tell application "AppleScript Editor" to activate

请注意,如果您尝试重新创建它,则窗口数和行数可能会有所不同。此外,最后一行只是为了方便,与代码无关。

在 AppleScript 编辑器的结果窗口中,我有以下内容:

perform action 1 of static text "Smart Collections" of group 1 of row 11 of outline 1 of scroll area 1 of window 6 of process "Lightroom"
    --> action "AXShowMenu" of static text "Smart Collections" of group 1 of row 11 of outline 1 of scroll area 1 of window 6 of application process "Adobe Photoshop Lightroom 5"

这意味着我确实调用了该操作。

但是……什么也没有发生。

任何见解,解决方法等都受到高度赞赏。

提前致谢。

4

1 回答 1

1

我在Lightroom 4上尝试了你的脚本,这里的结果相同。

有些应用程序需要真正的点击。

尝试这个

tell application "System Events"
    tell process "Lightroom"
        set frontmost to true
        set {x, y} to position of text field 1 of row 11 of outline 1 of scroll area 1 of window 6
        my realClick(x, y, "Right") -- "Right" = mouseRight, "Left" = mouseLeft
        delay 0.5
        key code 125 -- arrow down to select first menuitem
        keystroke return -- to click on menuitem
    end tell
end tell

on realClick(x, y, leftRight)
    do shell script "/usr/bin/python -c 'import Quartz.CoreGraphics  as qcg
def mouseEvent(type):
    e=qcg.CGEventCreateMouseEvent(None, type, (" & x & "," & y & "), r)
    qcg.CGEventPost(qcg.kCGHIDEventTap, e)

if \"" & leftRight & "\" is \"Left\": r= qcg.kCGMouseButtonLeft; mouseEvent(qcg.kCGEventLeftMouseDown); mouseEvent(qcg.kCGEventLeftMouseUp)
else: r= qcg.kCGMouseButtonRight; mouseEvent(qcg.kCGEventRightMouseDown); mouseEvent(qcg.kCGEventRightMouseUp)'"
end realClick
于 2014-10-07T14:10:54.313 回答