2012-07-29 70 views
1

This SO answer指出我進一步在腳本中更改新的MacBook Retina屏幕分辨率。我被困在這裏:Applescript獲取元素

enter image description here

我能到達此窗格與此腳本:

tell application "System Preferences" 
    activate 
    set the current pane to pane id "com.apple.preference.displays" 
    reveal anchor "displaysDisplayTab" of current pane 
    get elements of current pane 
    tell application "System Events" 

    end tell 
    --get the name of every anchor of current pane 
end tell 

但如何知道如何選擇,如果此窗格中的內容的位?如何引用「Scale」單選按鈕,並選擇5種可能的分辨率之一?由於

+1

我沒有帶有視網膜顯示器的Mac,但單選按鈕是「告訴應用程序」「系統事件」,以將過程「系統偏好設置」告訴給窗口1'的標籤組1的單選按鈕4。您可以使用'UI元素'縮小元素的範圍。通常可以通過'click'或'執行操作'AXPress「of'來選擇它們。 – user495470 2012-07-30 11:43:48

回答

3

我發現了這片的AppleScript,顯然檢索可用每個UI元素在一個窗口:

tell application "System Events" 
tell process "Process Name" 
set visible to true 
return every UI element of front window 
return name of every UI element of front window 
end tell 
end tell 

(沒有測試過自己尚未找到here。)