Macos 是否使用AppleScript在不可见的情况下更改系统首选项?

Macos 是否使用AppleScript在不可见的情况下更改系统首选项?,macos,applescript,Macos,Applescript,我想在用户看不到事情发生的情况下更改系统首选项中的设置。 如果我有一个脚本,它的开头如下: tell application "System Preferences" activate set current pane to pane "com.apple.preference.sound" end tell 系统首选项窗口将显示给用户。 我想知道是否有一种方法可以在后台进行,或者至少保持窗口最小化 (可以找到示例脚本。)您可能可以使用命令行应用程序执行您想要的操作,还有一些其

我想在用户看不到事情发生的情况下更改系统首选项中的设置。
如果我有一个脚本,它的开头如下:

tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.sound"
end tell
系统首选项窗口将显示给用户。
我想知道是否有一种方法可以在后台进行,或者至少保持窗口最小化


(可以找到示例脚本。)

您可能可以使用命令行应用程序执行您想要的操作,还有一些其他命令行应用程序可以操作其他系统功能,例如


也可以使用脚本添加来设置某些内容,例如,可以使用标准添加来设置系统卷,您还可以找到其他脚本添加来添加更多内容。

您可以使用命令行应用程序执行所需操作,还有一些其他的命令行应用程序可以操作其他系统的东西,比如


也可以使用脚本添加来设置某些内容,例如,可以使用标准添加来设置系统卷,您还可以找到其他脚本添加来添加更多内容。

您只需删除激活命令即可。系统事件可以在隐藏窗口中执行操作

tell application "System Preferences"
    reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Preferences"
如果打开菜单,它们将可见

tell application "System Preferences"
    reveal anchor "TTS" of pane "com.apple.preference.speech"
end tell
tell application "System Events" to tell process "System Preferences"
    tell pop up button 1 of tab group 1 of window 1
        delay 0.1
        click
        if value is "Alex" then
            click menu item "Kathy" of menu 1
        else
            click menu item "Alex" of menu 1
        end if
    end tell
end tell
quit application "System Preferences"

显示器的亮度也可以通过更改。

您只需删除激活命令即可。系统事件可以在隐藏窗口中执行操作

tell application "System Preferences"
    reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
tell application "System Events" to tell process "System Preferences"
    click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Preferences"
如果打开菜单,它们将可见

tell application "System Preferences"
    reveal anchor "TTS" of pane "com.apple.preference.speech"
end tell
tell application "System Events" to tell process "System Preferences"
    tell pop up button 1 of tab group 1 of window 1
        delay 0.1
        click
        if value is "Alex" then
            click menu item "Kathy" of menu 1
        else
            click menu item "Alex" of menu 1
        end if
    end tell
end tell
quit application "System Preferences"

显示器的亮度也可以通过更改。

您想更改什么设置?今天是亮度设置,但我希望明天有一个通用解决方案。:)您想更改什么设置?今天是亮度设置,但我希望明天有一个通用解决方案。:)很酷!不确定这一次它是否会对我有所帮助,但对将来的问题很有用!很酷!不确定这一次它是否会对我有所帮助,但对将来的问题很有用!