首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AppleScript: Lightroom 5:智能收集面板中的动作"AXShowMenu“不显示上下文菜单

AppleScript: Lightroom 5:智能收集面板中的动作"AXShowMenu“不显示上下文菜单
EN

Stack Overflow用户
提问于 2014-10-07 11:38:58
回答 1查看 636关注 0票数 0

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

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

根据堆栈溢出和其他地方的文档和各种来源,AXShowMenu应该打开该菜单。

到目前为止,我还没有能够使上下文菜单弹出。

使用UIElementInspector和UI浏览器,我定位了具有AXShowMenu操作的元素。基于UI浏览器提供的代码,我从Applescript编辑器获得了以下脚本:

代码语言:javascript
复制
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编辑器的结果窗口中,我有以下内容:

代码语言:javascript
复制
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"

这意味着我确实启动了行动。

但是…什么都没发生。

任何洞察力、解决办法等都会受到高度赞赏。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-07 14:10:54

我在Lightroom 4上试用您的脚本,这里的结果是相同的。

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

尝尝这个

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26235153

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档