2012-07-29 73 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。)