6 Replies Latest reply on Dec 18, 2009 2:29 AM by sstanleyau

    tell application CS2 or CS3

    Mahesh_JW Level 1

      Hi all

      I am new to applescript

      I want a single applescript that can run both CS2 and CS3

       

       

      This is my code

       

      tell application "Finder"
          set p to path to me as string
          --display dialog p as string
          if p contains "CS2" then
              set myApp to application "Adobe InDesign CS2"
             
          else if p contains "CS3" then
              set myApp to application "Adobe InDesign CS3"
          end if
         
          activate myApp
          starts()
      end tell

       

       

      but it is not working

      Please help

       

       

      Thanks in Advance....

        • 1. Re: tell application CS2 or CS3
          tobias.wantzen Level 1

          Hello Mahesh,

           

          I worked on the same issue recently and this is my result:

           

          set myApps to {"Adobe InDesign CS2", "Adobe InDesign CS3"}
          tell application "Finder"
               set frontApp to name of the first process whose frontmost is true
               if frontApp is in myApps then
                    set IDversion to last character of frontApp
               end if
          end tell
          if IDversion is "2" then
               tell application (item 1 of myApps)
                    display dialog "CS2:  " & version
               end tell
          else if IDversion is "3" then
               tell application (item 2 of myApps)
                    display dialog "CS3:  " & version
               end tell
          end if
          
          

           

          I read, that adressing apps in tell statements with variables isn't the high art of programming, but it works :-) If anyone has another (better) solution: I'm very interested ...

           

          Cheers

          Tobias

          • 2. Re: tell application CS2 or CS3
            liedzeit Level 2

            You can try something like this:

             

            try

            tell application "Finder" to set myApp to name of (first process whose creator type is "InDn" and name contains "CS2")

            on error

            tell application "Finder" to set myApp to name of (first process whose creator type is "InDn" and name contains "CS3")

            end try

             

             

            But this is not very reliable in my experience.

             

            Ralf

            • 3. Re: tell application CS2 or CS3
              Dirk Becker  Level 4

              There is a shorter way to address an application by creator type rather than by name.

               

              I have no idea how far that will improve reliability, I think the first running process (if any) with that creator will be addressed, otherwise the last launched application.

               

              Dirk

               

               

              tell application id "InDn"

              get number of documents

              end tell


              • 4. Re: tell application CS2 or CS3
                sstanleyau Level 4

                As of 10.5, you can use the id:

                 

                  tell application id "com.adobe.InDesign"

                That will address the running version, although if none is running, as Dirk says it's a bit of a toss-up.
                As long as you save as a compiled script or applet, you can also just use the normal form:

                  tell application "Adobe InDesign CS2"

                 

                If another version is running when you run such a script, it should just address the running version. What gets saved in the script is not just the literal name of the app.

                 

                If you want a script to address a particular version at all times, you need to include the full path to the app.

                • 5. Re: tell application CS2 or CS3
                  Dirk Becker  Level 4

                  Thanks Shane, that's an interesting addition.

                   

                  My reference machine for CS2 is still 10.3.9 - the operating system when CS2 came out - so I would not depend on 10.5 features in anything meant for so old software.

                   

                  Dirk

                  • 6. Re: tell application CS2 or CS3
                    sstanleyau Level 4

                    Right, although believe it or not, I know of one large US newspaper running CS2 under 10.6.x. And 10.6's ASObjC opens up all sorts of possibilities...