开发者

scripting "system preferences" "language & text"

开发者 https://www.devze.com 2023-01-22 14:53 出处:网络
I need to change, using applescript,开发者_Python百科 the listbox \"region\", in the system preferences|language & text section. I can\'t access this listbox - see code below.

I need to change, using applescript,开发者_Python百科 the listbox "region", in the system preferences|language & text section. I can't access this listbox - see code below.

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


GUI scripting is always a challenge iand isn't always reliable but here you go

 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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号