Skip to main content
Known Participant
December 18, 2013
Question

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

  • December 18, 2013
  • 1 reply
  • 1900 views

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

This topic has been closed for replies.

1 reply

Willam van Weelden
Inspiring
December 19, 2013

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

Known Participant
December 23, 2013

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

Willam van Weelden
Inspiring
December 26, 2013

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