Standard Configuration of Mojave 10.14 in Mission Control is, that "Displays use separate spaces" is checked.
I want it unchecked...
Is there a way to do this with applescript/osascript?
This is what i tried but its not clicking on the checkbox..
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"
When running your code, it stays in the repeat while not ...
loop because the target checkbox is not directly under the window but a part of a group.
Adding to tell group 2
to to tell window "Mission Control"
fixes it.
Change:
tell application "System Events" to tell process "System Preferences" to tell window "Mission Control"
To:
tell application "System Events" to tell process "System Preferences" to tell window "Mission Control" to tell group 2
Note: When checking/unchecking the Displays have separate Spaces checkbox, it requires a logout for the change to take effect.