5 Replies Latest reply on Apr 22, 2009 3:14 PM by Steven..

    How to know if ID is running

    Malcolm Wooden

      I have a VB script to check a document in ID3. When I run the script it will start ID3 if it is not already running. This is not what I want because the user should already have ID3 running and a document open when they run the script.

       

      Is there a way to check if ID3 is running from the script and if it isn't to have a return so that the script will stop? I woulds also like to do the same if there is not a document open in ID3.

       

      thanks

        • 1. Re: How to know if ID is running
          Kasyan Servetsky Level 5

           

          You can do this in JS: BridgeTalk.isRunning("indesign");

           

          Here is a function from my script:

           

          function CheckPhotoshop() { 
              var mySpecifier = BridgeTalk.getSpecifier("photoshop");
              if (mySpecifier == null) err(localize({en: 'The script can\'t run because Photoshop is not installed.', ru: 'Скрипт нельзя запустить, поскольку Фотошоп не установлен.'}));
              var myPS_version = mySpecifier.search(/\d+/);
              if (myPS_version < 10) err(localize({en: 'The script requires Photoshop at least version \"11\", but you have version \"', ru: 'Для работы скрипта необходим по крайней мере Фотошоп версии \"11\", а у вас установлена '}) + myPS_version + localize({en: '\" installed.', ru: ' версия.'}));
              if (!BridgeTalk.isRunning ("photoshop")) {
                  var myConfirm = confirm(localize({en: 'Photoshop is not running. Do you want to launch it?', ru: 'Фотошоп не запущен. Хотите его запустить?'}), false, localize({en: 'Resize Images Script', ru: 'Пересчёт картинок'}));
                  if (myConfirm) {
                      BridgeTalk.launch("photoshop");
                      err(localize({en: 'Wait untill Photoshop finishes loading and run the script again.', ru: 'Подождите пока загрузиться Фотошоп и запустите скрипт снова'}), false);
                  }
                  else {
                      exit();
                  }
              }
          }

           

          It checks if Photoshop is installed and running, but the same should work for InDesign too.

          1 person found this helpful
          • 2. Re: How to know if ID is running
            AdobeScripts Level 3

            Malcolm Wooden wrote:

             

            I have a VB script to check a document in ID3. When I run the script it will start ID3 if it is not already running. This is not what I want because the user should already have ID3 running and a document open when they run the script.

             

            why you can't stop your script - or only pause with some message - if there is no open document ?

             

            robin

             

            www.adobescripts.com

            • 3. Re: How to know if ID is running
              Malcolm Wooden Level 1

              Kasyan

               

              Thanks for the suggestion. It looked like that could have been the answer but Bridge seems to be JS only, there is no COM for Bridge in Windows and VB.

              • 4. Re: How to know if ID is running
                Kasyan Servetsky Level 5

                I thought it would be possible to work around this via DoScript function:

                 

                Private Sub Form_Load()
                    Set myInDesign = CreateObject("InDesign.Application.CS3")
                    myJavaScript = "if (BridgeTalk.isRunning ('indesign')) {" & vbCr
                    myJavaScript = myJavaScript & "var myQuery = 'Running';" & vbCr
                    myJavaScript = myJavaScript & "}" & vbCr
                    myJavaScript = myJavaScript & "else {" & vbCr
                    myJavaScript = myJavaScript & "var myQuery = 'Not running';" & vbCr
                    myJavaScript = myJavaScript & "}"
                    myJavaScript = myJavaScript & "app.scriptArgs.setValue('ScriptArgument', myQuery);" & vbCr
                    myInDesign.DoScript myJavaScript, idScriptLanguage.idJavascript
                    myScriptArgument = myInDesign.ScriptArgs.GetValue("ScriptArgument")
                    MsgBox myScriptArgument
                End Sub

                 

                But I was mistaken – ID launches before it is executed, right after the first line:

                Set myInDesign = CreateObject("InDesign.Application.CS3")

                It can be easily done in JS, but non in VB.

                • 5. Re: How to know if ID is running
                  Steven.. Level 3

                  Its really easy using vbs

                   

                  Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
                  Set colProcessList = objWMIService.ExecQuery("SELECT * FROM WIN32_PROCESS WHERE name = 'InDesign.exe'")
                  if colProcessList.count then
                  msgbox "InDesign is running"
                  else
                  msgbox "InDesign is not running"
                  end if

                   

                  Steven

                  http://scriptui.com