2012-02-18 62 views
0

如何獲得UI_element性質,我想寫在appscript.rb相當於代碼的AppleScript:與appscript

tell App "TextEdit" 
    properties of front window 
end tell 

試圖

te = app("TextEdit") 
puts  te.windows[1].properties 

收益屬性名稱,但沒有值的列表。

感謝回答。

回答

0

等效於AppleScript的properties引用的Ruby Appscript具有尾部下劃線:properties_。你還需要使用get執行查詢:

te = Appscript.app('TextEdit') 
te.windows.first.properties_.get 

最後一個表達式的結果將是Ruby的哈希類的一個實例。


你的問題的標題提到UI_element,這可能表明你有興趣可以從系統事件UI elements對象。

se = Appscript.app('System Events') 
teap = se.application_processes['TextEdit'] 

# properties of frontmost UI element window 
teap.windows.first.properties_.get 

# properties of first-level UI elements of frontmost UI element window 
teap.windows.first.UI_elements.properties_.get