1

任务控制中 Mojave 10.14 的标准配置是选中“显示使用单独的空间”。

我希望它不被选中...

有没有办法用 applescript/osascript 做到这一点?

这是我尝试过的,但它没有点击复选框..

if application "System Preferences" is running then quit application 
"System Preferences"
repeat until application "System Preferences" is not running
    delay 0.1
end repeat
tell application "System Preferences" to reveal pane id "com.apple.preference.expose"

tell application "System Events" to tell process "System Preferences" to 
tell window "Mission Control"
    repeat while not (exists of checkbox "Displays have separate Spaces")
        delay 0.1
    end repeat
    click checkbox "Displays have separate Spaces"
end tell

quit application "System Preferences"
4

1 回答 1

1

运行代码时,它会停留在repeat while not ...循环中,因为目标复选框不在窗口的正下方,而是group的一部分。

添加to tell group 2to tell window "Mission Control"修复它。

改变:

tell application "System Events" to tell process "System Preferences" to tell window "Mission Control"

至:

tell application "System Events" to tell process "System Preferences" to tell window "Mission Control" to tell group 2

注意:选中/取消选中Displays have separate Spaces复选框时,需要注销才能使更改生效。

于 2018-11-23T12:59:16.723 回答