Osascript/Applescript: Uncheck “Displays have separate Spaces”





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















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"









share|improve this question




















  • 1





    Your code as posted has two linefeeds that shouldn't be there, and one causes a compile error while the other causes Script Editor to want to quit. After fixing that and running the code, it stays in the repeat while not ... loop (on macOS High Sierra anyway) 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. Since I'm not running macOS Mojave yet, I can't confirm if this fixes it there too, but it gives you a direction to look.

    – user3439894
    Nov 23 '18 at 11:56






  • 1





    BTW Under macOS High Sierra it requires a logout for the change to take effect, not sure if it's still required in macOS Mojave.

    – user3439894
    Nov 23 '18 at 12:07











  • Thank you very much!!! It is working with "to tell window "Mission Control" to tell group 2". And yes, Mojave still requires a restart :) !!! You can post it as an answer if u want, so i can accept it

    – pr0cat
    Nov 23 '18 at 12:54




















1















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"









share|improve this question




















  • 1





    Your code as posted has two linefeeds that shouldn't be there, and one causes a compile error while the other causes Script Editor to want to quit. After fixing that and running the code, it stays in the repeat while not ... loop (on macOS High Sierra anyway) 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. Since I'm not running macOS Mojave yet, I can't confirm if this fixes it there too, but it gives you a direction to look.

    – user3439894
    Nov 23 '18 at 11:56






  • 1





    BTW Under macOS High Sierra it requires a logout for the change to take effect, not sure if it's still required in macOS Mojave.

    – user3439894
    Nov 23 '18 at 12:07











  • Thank you very much!!! It is working with "to tell window "Mission Control" to tell group 2". And yes, Mojave still requires a restart :) !!! You can post it as an answer if u want, so i can accept it

    – pr0cat
    Nov 23 '18 at 12:54
















1












1








1


0






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"









share|improve this question
















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"






bash terminal applescript osascript mission-control






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 11:26







pr0cat

















asked Nov 23 '18 at 11:01









pr0catpr0cat

537




537








  • 1





    Your code as posted has two linefeeds that shouldn't be there, and one causes a compile error while the other causes Script Editor to want to quit. After fixing that and running the code, it stays in the repeat while not ... loop (on macOS High Sierra anyway) 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. Since I'm not running macOS Mojave yet, I can't confirm if this fixes it there too, but it gives you a direction to look.

    – user3439894
    Nov 23 '18 at 11:56






  • 1





    BTW Under macOS High Sierra it requires a logout for the change to take effect, not sure if it's still required in macOS Mojave.

    – user3439894
    Nov 23 '18 at 12:07











  • Thank you very much!!! It is working with "to tell window "Mission Control" to tell group 2". And yes, Mojave still requires a restart :) !!! You can post it as an answer if u want, so i can accept it

    – pr0cat
    Nov 23 '18 at 12:54
















  • 1





    Your code as posted has two linefeeds that shouldn't be there, and one causes a compile error while the other causes Script Editor to want to quit. After fixing that and running the code, it stays in the repeat while not ... loop (on macOS High Sierra anyway) 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. Since I'm not running macOS Mojave yet, I can't confirm if this fixes it there too, but it gives you a direction to look.

    – user3439894
    Nov 23 '18 at 11:56






  • 1





    BTW Under macOS High Sierra it requires a logout for the change to take effect, not sure if it's still required in macOS Mojave.

    – user3439894
    Nov 23 '18 at 12:07











  • Thank you very much!!! It is working with "to tell window "Mission Control" to tell group 2". And yes, Mojave still requires a restart :) !!! You can post it as an answer if u want, so i can accept it

    – pr0cat
    Nov 23 '18 at 12:54










1




1





Your code as posted has two linefeeds that shouldn't be there, and one causes a compile error while the other causes Script Editor to want to quit. After fixing that and running the code, it stays in the repeat while not ... loop (on macOS High Sierra anyway) 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. Since I'm not running macOS Mojave yet, I can't confirm if this fixes it there too, but it gives you a direction to look.

– user3439894
Nov 23 '18 at 11:56





Your code as posted has two linefeeds that shouldn't be there, and one causes a compile error while the other causes Script Editor to want to quit. After fixing that and running the code, it stays in the repeat while not ... loop (on macOS High Sierra anyway) 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. Since I'm not running macOS Mojave yet, I can't confirm if this fixes it there too, but it gives you a direction to look.

– user3439894
Nov 23 '18 at 11:56




1




1





BTW Under macOS High Sierra it requires a logout for the change to take effect, not sure if it's still required in macOS Mojave.

– user3439894
Nov 23 '18 at 12:07





BTW Under macOS High Sierra it requires a logout for the change to take effect, not sure if it's still required in macOS Mojave.

– user3439894
Nov 23 '18 at 12:07













Thank you very much!!! It is working with "to tell window "Mission Control" to tell group 2". And yes, Mojave still requires a restart :) !!! You can post it as an answer if u want, so i can accept it

– pr0cat
Nov 23 '18 at 12:54







Thank you very much!!! It is working with "to tell window "Mission Control" to tell group 2". And yes, Mojave still requires a restart :) !!! You can post it as an answer if u want, so i can accept it

– pr0cat
Nov 23 '18 at 12:54














1 Answer
1






active

oldest

votes


















1














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.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445442%2fosascript-applescript-uncheck-displays-have-separate-spaces%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    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.






    share|improve this answer




























      1














      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.






      share|improve this answer


























        1












        1








        1







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 23 '18 at 12:59









        user3439894user3439894

        1,83231120




        1,83231120
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445442%2fosascript-applescript-uncheck-displays-have-separate-spaces%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            RAC Tourist Trophy