2016-04-27 153 views
0

我正在开发一个applescript以便于FCPX中的某些工作流程10.2.3 我正在使用UI脚本执行此任务。 我想在某个文件列表(事件浏览器)中选择两个或多个资产。我可以处理浏览器中的行并选择它们,但我一次只能实现一个选择。通过UI脚本从applescript中选择多个UI元素

select *soundfile* 

set selected of *soundfile* to true 

set value of attribute "AXSelected" of soundfile to true 

其中音效档是例如

row 5 of outline 1 of scroll area 1 of splitter group 1 of splitter group 1 of group 5 of splitter group 1 of window "Final Cut Pro" 

工作正常。只有它取消选择所有其他行。

我想找到一种方法来发送命令选择到应用程序。

另一个想法: 有问题的元素的父元素有一个属性“AXSelectedRows”,但我无法与它的东西。 如果它不是空的,它将返回一个数组,项目值为'application'System Events'' 所以我认为它没有真正实现。

有没有办法实现多选?

不必是苹果脚本...

回答

1

在Applescript中有一个错误。您可以将UI元素的选定属性设置为false而不更改其他选定元素,但如果将其设置为true,则会取消选择所有其他UI元素。

我也尝试玩“按键{命令}”和“点击”,但没办法。我找到的唯一解决方法是选择所有行并取消选择不需要的行。

下面的脚本是Mail中多行选择的示例。它首先使用“命令”快捷方式选择所有行(框中的所有消息),并取消选择不在列表Rows_to_Select中的所有行。

tell application "Mail" to activate -- just to make it front window 
set Rows_to_Select to {1, 3, 5} -- the rows you want to select 
tell application "System Events" 
tell process "Mail" 
    tell table 1 of scroll area 1 of group 1 of splitter group 1 of splitter group 1 of front window 
     keystroke "a" using command down -- select all rows 
     repeat with I from 1 to count of rows 
      if I is not in Rows_to_Select then set selected of row I to false 
     end repeat 
    end tell 
end tell 
end tell 
+0

谢谢! 不幸的是,在我的情况下,取消选择一个元素需要1/3s到1/2s。整个列表将在80到400个条目之间;) 其实我做了类似的事情,直到我找到更好的解决方案:我计算行号的最大差异,选择行号最低的行,然后发送shift-arrow_down到所涉及的窗口,直到所有项目都包含在选择中。然后按照你提到的那样去做取消选择循环。 –