2016-04-27 154 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到所涉及的窗口,直到所有項目都包含在選擇中。然後按照你提到的那樣去做取消選擇循環。 –