7 Replies
      Latest reply on Aug 9, 2019 12:29 AM by eskimo
      SivaShankar Level 1 Level 1 (0 points)

        My application should wait for an applications to load completely. I have the process id of the application.

         

        Do we have any function in Objective-C/swift to check if an application is launched?

        • Re: Wait for a process to finish launching
          eskimo Apple Staff Apple Staff (12,305 points)

          My application should wait for an applications to load completely.

          What platform are you working on?

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"

          • Re: Wait for a process to finish launching
            wei97 Level 1 Level 1 (0 points)

            How long you are waiting for launching? We are also experienceing the same problem. It always shows that "your enrollment is being processed".

            • Re: Wait for a process to finish launching
              eskimo Apple Staff Apple Staff (12,305 points)

              Can you modify the app being launched?

              Share and Enjoy

              Quinn “The Eskimo!”
              Apple Developer Relations, Developer Technical Support, Core OS/Hardware
              let myEmail = "eskimo" + "1" + "@apple.com"

                • Re: Wait for a process to finish launching
                  SivaShankar Level 1 Level 1 (0 points)

                  No, I don't have access to modify the app that is being launched.

                   

                  My app has to wait for Safari or Microsoft Office applications to launch properly before it start performing any of the operations.

                    • Re: Wait for a process to finish launching
                      eskimo Apple Staff Apple Staff (12,305 points)

                      The problem here is “launch properly”.  There isn’t a universal definition of that term.  For example, when you launch iTunes for the first time, it presents a modal alert requiring you to agree to its licence.  Is it “launched properly” at that point?

                      The best suggestion I can think of right now is to send the app an Apple event.  When and if it responds, you can be reasonably assured that the app’s main event loop is up and limping.

                      Weirdly, given that Apple events are so feature rich, I don’t think there’s a no-op Apple event you can use.  One option would be to target the current date scripting addition.  For example, the Apple event equivalent of this:

                      tell application "Safari"
                          current date
                      end tell

                      You can prototype this with an AppleScript like this one, but I recommend that you distill this down to a single Apple event for production use.

                      Share and Enjoy

                      Quinn “The Eskimo!”
                      Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                      let myEmail = "eskimo" + "1" + "@apple.com"