Commands & Syntax > Commands > Run/Execute >

www.perfectkeyboard.com

 

EXTERNAL COMMAND - < extcmd >() ... [Pro]

 

Run EXTERNAL COMMAND
<extcmd>("Command executable","Parameters",Timeout (seconds),Variable receiving result)
Available in: Professional edition

This command executes an external command. The external commands allows to extend the macro language capabilities by adding new commands. The external command can be any executable file that takes parameters (optionally) and prints result to standard output. The macro engine takes the printed result from standard output and assigns it to user-defined macro language result variable.

Note: The external command can be written in VBS, for example. However, the VBS engine outputs some copyright information at the start of the script execution. If the user does not want to have such the information as a part of own script result then the user can put this line at the begin of VBS script:

Wscript.StdOut.Write ">>>cmd_results>>>"

This line tells the macro engine where actual results start and the macro engine then ignores the output printed before.

 

#

Parameter name

Parameter description

1

Command executable

(Full) path to an executable file or just a name with ".ec...." extension (for example, "SimplePing.ec.vbs"). If the full path is not supplied then the executable file must be located in "ExternalCommands" sub-folder in installation folder or in the same folder where calling macro file is located.

2

Parameters

Parameters that will be passed to the external command. The number of the parameters depends on the external command.

3

Timeout (seconds)

Timeout in seconds. If the external command does not finishes its execution in the defined timeout then the command fails.

4

Variable receiving result

This is the user-defined variable that will receive the external command result.

 

Example (Macro Steps):

 

1

<#> <#> This command pings to the www.pitrinec.com web site

2

Macro execution: ONLY COMMANDS

3

Run EXTERNAL COMMAND Command executable = "SimplePing.ec.vbs", Parameters = "www.pitrinec.com", Timeout (seconds) = "15", Variable receiving result = "vResult"

4

IF STRING vResult==1

5

Message SHOW "Information" : "Ping OK." (other parameters: x = -100, y = -100, Window title = Message, Buttons = OK, Timeout (seconds) = 0, Always on top = ).

6

ELSE activate

7

Message SHOW "Information" : "Ping failed." (other parameters: x = -100, y = -100, Window title = Message, Buttons = OK, Timeout (seconds) = 0, Always on top = ).

8

ENDIF

Example (Plain Text):

 

<#> This command pings to the www.pitrinec.com web site

<cmds>

<extcmd>("SimplePing.ec.vbs","www.pitrinec.com",15,vResult)

<if_str>("vResult==1")

   <msg>(-100,-100,"Ping OK.","Message",1,0,0)

<else>

   <msg>(-100,-100,"Ping failed.","Message",1,0,0)

<endif>