3 Replies Latest reply on Dec 26, 2013 12:53 AM by Willam van Weelden

    Is there a way I can call a python script from within a Robohelp script?

    laurenkusa

      Hi,

       

      I want to integrate an external python script into the current extendscript I use in RoboHelp 10.  Is there a way to do that?

       

      Thanks,

       

      Lauren

        • 1. Re: Is there a way I can call a python script from within a Robohelp script?
          Willam van Weelden Adobe Community Professional & MVP

          You can use the command line to call any kind of external application.

          Personally, I use the following function to create bat files to do such

          work.

           

          I've taken these functions from my free RH Extendscript library -

          http://www.wvanweelden.eu/product/robohelp-extendscript-library

           

          function ExecuteBatchFile(command, waitforbatch) {

           

               if(string_isEmpty(command))

                   return false;

           

               if(!waitforbatch) {

                   if(waitforbatch != false) {

                       waitforbatch = true;

                   }

               }

           

               var path = Folder.appData.fsName + '/';

           

               var batFileName = 'ExtendScriptBatchFile';

               var batFileExtension = '.bat';

               var batFile = new File(pathbatFileNamebatFileExtension);

               if(batFile.exists) {

                   var i  = 0;

                   while(batFile.exists) {

                       i++;

                       batFile = new File(pathbatFileNamei+batFileExtension);

                   }

               }

           

               command+= "\ndel /F /Q \"" + batFile.fsName + "\"";

           

               writeFile(batFile, command, false);

               if(!isFile(batFile, true))

                   return false;

           

               batFile.execute();

           

               /* Wait on batch file execution if needed */

               if(waitforbatch) {

                   while(batFile.exists) {

                       msg(".");

                       $.sleep(100);

                   }

               }

               return true;

          }

          function writeFile(file, szOutput, encoding) {

               var szFilePath = file.fsName;

           

               if(!encoding || encoding == true) {

                  encoding = "UTF-8";

               }

           

               var fileObj = new File(szFilePath);

               fileObj.encoding = encoding;

               fileObj.open("w");

               fileObj.write(szOutput);

               fileObj.close();

          }

           

          Kind regards,

           

          Willam

          • 2. Re: Is there a way I can call a python script from within a Robohelp script?
            laurenkusa Level 1

            William,

             

            I am not all that familiar with Javascript or extendscript.  Can you provide a link to something that provides more detail about using the command-line?

             

            Thanks,

             

            Lauren

            • 3. Re: Is there a way I can call a python script from within a Robohelp script?
              Willam van Weelden Adobe Community Professional & MVP

              For the function mentioned above, create a string with the cmd command:

               

              var cmd = "python -myparameters"

              ExecuteBatchFile(cmd, true);

               

              Just make sure to make the functions of my previous post available in

              your script.

               

              Kind regards,

               

              Willam