2010-10-31 76 views
0

我需要在系統首選項|語言&文本部分中使用applescript,列表框「區域」進行更改。我無法訪問此列表框 - 請參閱下面的代碼。腳本編寫「系統偏好設置」「語言和文本」

tell application "System Preferences" 
    activate 
    get the name of every pane of application "System Preferences" 
    set the current pane to pane id "com.apple.Localization" 
    get the name of every anchor of pane id "com.apple.Localization" 
    reveal anchor "Formats" of pane id "com.apple.Localization" 
end tell 

回答

2

GUI腳本始終是一個挑戰IAND並不總是可靠的,但在這裏你去

tell application "System Preferences" 
    activate 
    get the name of every pane of application "System Preferences" 
    set the current pane to pane id "com.apple.Localization" 
    get the name of every anchor of pane id "com.apple.Localization" 
    reveal anchor "Formats" of pane id "com.apple.Localization" 

end tell 

tell application "System Events" 
    tell application process "System Preferences" 
     click pop up button 1 of tab group 1 of window 1 
     repeat 23 times 
      keystroke (ASCII character 30) -- got to the top 
     end repeat 
     repeat 21 times 
      keystroke (ASCII character 31) -- down to second to last 
     end repeat 
     keystroke return 
    end tell 
end tell 
+0

這正是我需要的,謝謝。 – jbastos 2010-11-02 00:40:05