Applescript to close box by hitting ok automatically












0















I need to create a script that automatically closes a popup box that opens approximately every 55 - 65 seconds. Once the box opens, you merely hit OK (within the box) and it closes.



I created an applescript application but found that I still need to hit manually run the script for it to work.



on idle
tell application "XYZ"
activate
tell application "System Events" to key code 36
end tell
return 65
end idle



  1. Instead of specifying a time, in this case 65 seconds, can I not say; if the dialog box opens click the OK button. In that way anytime the box opens, it will be closed without disturbing me whilst I work on the application.

  2. I'd really only like the script to be activated at the time, the window/popup shows up and not before.

  3. The script should be active, whilst I use the application (XYZ). How long I will use XYZ will vary.










share|improve this question





























    0















    I need to create a script that automatically closes a popup box that opens approximately every 55 - 65 seconds. Once the box opens, you merely hit OK (within the box) and it closes.



    I created an applescript application but found that I still need to hit manually run the script for it to work.



    on idle
    tell application "XYZ"
    activate
    tell application "System Events" to key code 36
    end tell
    return 65
    end idle



    1. Instead of specifying a time, in this case 65 seconds, can I not say; if the dialog box opens click the OK button. In that way anytime the box opens, it will be closed without disturbing me whilst I work on the application.

    2. I'd really only like the script to be activated at the time, the window/popup shows up and not before.

    3. The script should be active, whilst I use the application (XYZ). How long I will use XYZ will vary.










    share|improve this question



























      0












      0








      0








      I need to create a script that automatically closes a popup box that opens approximately every 55 - 65 seconds. Once the box opens, you merely hit OK (within the box) and it closes.



      I created an applescript application but found that I still need to hit manually run the script for it to work.



      on idle
      tell application "XYZ"
      activate
      tell application "System Events" to key code 36
      end tell
      return 65
      end idle



      1. Instead of specifying a time, in this case 65 seconds, can I not say; if the dialog box opens click the OK button. In that way anytime the box opens, it will be closed without disturbing me whilst I work on the application.

      2. I'd really only like the script to be activated at the time, the window/popup shows up and not before.

      3. The script should be active, whilst I use the application (XYZ). How long I will use XYZ will vary.










      share|improve this question
















      I need to create a script that automatically closes a popup box that opens approximately every 55 - 65 seconds. Once the box opens, you merely hit OK (within the box) and it closes.



      I created an applescript application but found that I still need to hit manually run the script for it to work.



      on idle
      tell application "XYZ"
      activate
      tell application "System Events" to key code 36
      end tell
      return 65
      end idle



      1. Instead of specifying a time, in this case 65 seconds, can I not say; if the dialog box opens click the OK button. In that way anytime the box opens, it will be closed without disturbing me whilst I work on the application.

      2. I'd really only like the script to be activated at the time, the window/popup shows up and not before.

      3. The script should be active, whilst I use the application (XYZ). How long I will use XYZ will vary.







      macos applescript popups






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '13 at 6:24









      MoonSire

      8161825




      8161825










      asked Nov 19 '13 at 4:35









      AndyAndy

      111




      111






















          2 Answers
          2






          active

          oldest

          votes


















          0














          Try:



          set resultDialogReply to display dialog "Close after 5 seconds..." giving up after 5





          share|improve this answer































            0














            You might just run the loop every second or so:



            repeat
            if (exists application "XYZ") then
            tell application "System Events" to tell process "XYZ"
            if exists (button "OK" of window "Window Title") then
            click (button "OK" of window "Window Title")
            end if
            end tell
            end if
            delay 1
            end repeat


            If the window does not have a title, try replacing window "Window Title" with window 1, or run tell application "System Events" to tell process "XYZ" to properties of windows to see if the window can be identified some other way.






            share|improve this answer


























            • Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

              – Andy
              Nov 26 '13 at 12:05













            • @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

              – David Andreoletti
              Sep 20 '15 at 23:39











            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "3"
            };
            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%2fsuperuser.com%2fquestions%2f677765%2fapplescript-to-close-box-by-hitting-ok-automatically%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Try:



            set resultDialogReply to display dialog "Close after 5 seconds..." giving up after 5





            share|improve this answer




























              0














              Try:



              set resultDialogReply to display dialog "Close after 5 seconds..." giving up after 5





              share|improve this answer


























                0












                0








                0







                Try:



                set resultDialogReply to display dialog "Close after 5 seconds..." giving up after 5





                share|improve this answer













                Try:



                set resultDialogReply to display dialog "Close after 5 seconds..." giving up after 5






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 19 '13 at 12:36









                adayzdoneadayzdone

                58237




                58237

























                    0














                    You might just run the loop every second or so:



                    repeat
                    if (exists application "XYZ") then
                    tell application "System Events" to tell process "XYZ"
                    if exists (button "OK" of window "Window Title") then
                    click (button "OK" of window "Window Title")
                    end if
                    end tell
                    end if
                    delay 1
                    end repeat


                    If the window does not have a title, try replacing window "Window Title" with window 1, or run tell application "System Events" to tell process "XYZ" to properties of windows to see if the window can be identified some other way.






                    share|improve this answer


























                    • Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

                      – Andy
                      Nov 26 '13 at 12:05













                    • @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

                      – David Andreoletti
                      Sep 20 '15 at 23:39
















                    0














                    You might just run the loop every second or so:



                    repeat
                    if (exists application "XYZ") then
                    tell application "System Events" to tell process "XYZ"
                    if exists (button "OK" of window "Window Title") then
                    click (button "OK" of window "Window Title")
                    end if
                    end tell
                    end if
                    delay 1
                    end repeat


                    If the window does not have a title, try replacing window "Window Title" with window 1, or run tell application "System Events" to tell process "XYZ" to properties of windows to see if the window can be identified some other way.






                    share|improve this answer


























                    • Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

                      – Andy
                      Nov 26 '13 at 12:05













                    • @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

                      – David Andreoletti
                      Sep 20 '15 at 23:39














                    0












                    0








                    0







                    You might just run the loop every second or so:



                    repeat
                    if (exists application "XYZ") then
                    tell application "System Events" to tell process "XYZ"
                    if exists (button "OK" of window "Window Title") then
                    click (button "OK" of window "Window Title")
                    end if
                    end tell
                    end if
                    delay 1
                    end repeat


                    If the window does not have a title, try replacing window "Window Title" with window 1, or run tell application "System Events" to tell process "XYZ" to properties of windows to see if the window can be identified some other way.






                    share|improve this answer















                    You might just run the loop every second or so:



                    repeat
                    if (exists application "XYZ") then
                    tell application "System Events" to tell process "XYZ"
                    if exists (button "OK" of window "Window Title") then
                    click (button "OK" of window "Window Title")
                    end if
                    end tell
                    end if
                    delay 1
                    end repeat


                    If the window does not have a title, try replacing window "Window Title" with window 1, or run tell application "System Events" to tell process "XYZ" to properties of windows to see if the window can be identified some other way.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Nov 22 '13 at 13:34

























                    answered Nov 20 '13 at 9:28









                    user495470user495470

                    31k589127




                    31k589127













                    • Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

                      – Andy
                      Nov 26 '13 at 12:05













                    • @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

                      – David Andreoletti
                      Sep 20 '15 at 23:39



















                    • Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

                      – Andy
                      Nov 26 '13 at 12:05













                    • @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

                      – David Andreoletti
                      Sep 20 '15 at 23:39

















                    Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

                    – Andy
                    Nov 26 '13 at 12:05







                    Thanks for the feedback. Deleted other post.Made the following amendments:1. added in window 1 and I get an error - Can’t continue exists." number -1708

                    – Andy
                    Nov 26 '13 at 12:05















                    @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

                    – David Andreoletti
                    Sep 20 '15 at 23:39





                    @Andy Error -1708 is usually because the AppleScript excution environment does not know what context to send/call the method to. The context is specified by "tell application XYZ" / end tell. Alternatively, you need to specify the keyword my in from of the function being called: my computeFilesMissing

                    – David Andreoletti
                    Sep 20 '15 at 23:39


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Super User!


                    • 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%2fsuperuser.com%2fquestions%2f677765%2fapplescript-to-close-box-by-hitting-ok-automatically%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

                    Сан-Квентин

                    8-я гвардейская общевойсковая армия

                    Алькесар