3 Replies Latest reply: Apr 30, 2013 6:19 AM by Mac_06 RSS

    Unable to call applescript from extension[CS6]

    Mac_06 Community Member

      Hi,

       

      I need to mount the directory automatically through code. To accomplish this I've a Applescript but to run that script from action script I need do script to run. I saw the code in "http://forums.adobe.com/message/3238998" but I see actually there is no attribute called APPLESCRIPT_LANGUAGE in API. It has script language VB script and javascript but no applescript. I'm using flex 4 for InDesign CS6 Extension.

       

      var app:Application = InDesign.app;
          if(OS.toLowerCase() == 'mac')
             {
                 var applescript:File = new File("AutoMounting.scpt");
                     app.doScript(applescript.nativePath, ScriptLanguage.?);
        
              }
      
      
      

       

      Could some one help me out to get this done ?


      Many Thanks in advance.

       

      Mac

        • 1. Re: Unable to call applescript from extension[CS6]
          brianreavis

          To run the script, you can use the NativeProcess API to launch the native script utility ("osascript" on Mac). Here's a quick example:

           

          var scriptFile:File = new File('yourscript.scpt');
          var scriptUtility:File = new File('/usr/bin/osascript');
          if (scriptUtility.exists) {
               var processInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
               processInfo.executable = scriptUtility;
               processInfo.arguments = new Vector.();
               processInfo.arguments.push(scriptFile.nativePath);
          
               var process:NativeProcess = new NativeProcess();
               process.start(processInfo);
          }
          • 2. Re: Unable to call applescript from extension[CS6]
            Mac_06 Community Member

            Thanks a lot, it's allowing me to execute the applescript. Only thing I was wondering if could pass the parameter to applescript using above process because I need to pass the path of volume to be mounted.

            An important question I had is, scriptUtility file I'm not able to see. I guess it's a hidden directory correct ?

             

            Mac

            • 3. Re: Unable to call applescript from extension[CS6]
              Mac_06 Community Member

              I got it

               

              var scriptFile:File = new File('yourscript.scpt'); 
              var scriptUtility:File = new File('/usr/bin/osascript'); 
              if (scriptUtility.exists) 
              {
                    var processInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
                    processInfo.executable = scriptUtility;
                    processInfo.arguments = new Vector.();
                    processInfo.arguments.push(scriptFile.nativePath);
                    processInfo.arguments.push("your argument here");
              
              
                     var process:NativeProcess = new NativeProcess();
                    process.start(processInfo); 
              }
              

               

              And it will be executed perfectly.

               

              Thanks for help