iMacros Software Manual51
© 2001 - 2006 iOpus Software GmbH, all rights reserved.
the behaviour of the browser. The general command line syntax is
imacros -command_line_switch1 switch_value1 -command_line_switch2
switch_value2 ...
A command line that starts the iMacros Browser, executes the macro called YourMacroName and
passes a value to the built-in variable !VAR1 look like this:
imacros -macro YourMacroName -var1 Hello[SP]World!
After completing the macro, the iMacros Browser automatically stops and closes. Note that in
command lines you need to use the square brackets instead of the usual pointy brackets (< and >) to
escape a whitespace ([SP]) or linebreak ([BR]). This is because > and < are used for file
input/output operations on the Windows command line and thus the command does not execute
correctly.
You can now use batch files to conveniently execute several iMacros in a sequence:
echo Start iMacros batch file
imacros -macro FormExampleMacro
imacros -macro Check_Altavista
imacros -macro Buy_Now!
echo Done!
In the above macro the batch command echo is used to print messages to the standard output.
Other important command line switches are those setting variables. You can set the built-in variables
!VAR1, !VAR2 and !VAR3 using the following switch:
imacros -var1 iOpus[SP]iMacros
With the command line switch -var_varname you can create your own custom variable. Imagine,
you want to call a macro (searchEngine.iim) that enters the content of the variable
SEARCHSTRING into a search engine and presses submit. You can set the search value via the
command line:
imacros -macro searchEngine -var_SEARCHSTRING iOpus[SP]iMacros
If you want iMacros to read a value from the command line use the CMDLINE command in your
macro.
CMDLINE !VAR1 http://www.iOpus.com/iim.htm
SET !VAR2
[email protected]
TAG TYPE=INPUT:TEXT FORM=NAME:f1 ATTR=NAME:name CONTENT=Tom Tester!VAR1
Check on the return value at batch level
The iMacros executable imacros.exe sets the predefined batch file variable ERRORLEVEL. The
value is either 1 if the macro was completed successfully or negative if an error was encountered.
ERRORLEVEL is used almost exclusively with a conditional construct, e.g.:
imacros -macro searchEngine -var_SEARCHSTRING iOpus[SP]iMacros
IF NOT %ERRORLEVEL% == 1 ECHO Problem encountered
For more details please see the included example batch file "Example-Errorlevel.bat".
90