编写“系统首选项”脚本”语言与文本”

发布于 2024-09-30 08:58:21 字数 416 浏览 3 评论 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

I need to change, using applescript, 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

卖梦商人 2024-10-07 08:58:21

GUI 脚本始终是一个挑战,并且并不总是可靠,但是您可以使用

 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

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文