我们正在使用Lightroom 5(CC的最新版本),使用Applescript开发一个简单的自动化工具。
对于某些操作,我们需要智能集合面板中的上下文菜单,例如导入智能集合描述。
根据堆栈溢出和其他地方的文档和各种来源,AXShowMenu应该打开该菜单。
到目前为止,我还没有能够使上下文菜单弹出。
使用UIElementInspector和UI浏览器,我定位了具有AXShowMenu操作的元素。基于UI浏览器提供的代码,我从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"这意味着我确实启动了行动。
但是…什么都没发生。
任何洞察力、解决办法等都会受到高度赞赏。
提前谢谢。
发布于 2014-10-07 14:10:54
我在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 realClickhttps://stackoverflow.com/questions/26235153
复制相似问题