The renewal maintenance has officially ended for Progress iMacros effective November 30, 2023.
This Wiki site will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely, The Progress Team
iimPlay()
Plays a macro. After the macro has played all options that have been set with the iimSet command are reset. Use iimGetLastExtract to get the extracted text.
There are two fundamentally different ways of playing a macro using the iimPlay command. The first is to specify the filename (without the extension) of the macro in the String macro parameter. The other is to generate macro code on-the-fly in your program and pass it, preceded by CODE:, directly to iimPlay using the String macro parameter. Several commands in a macro generated on-the-fly must be separated by the CR (carriage return) symbol. These are vbNewLine or vbCrLf in Visual Basic or \r\n in C, C++ or C#.
If you start a macro via iimPlay which contains a TAG TYPE=SELECT... statement and the specified value is not in the drop down list then the iimPlay command returns an -251 error code. In the corresponding error message (see iimGetLastError) the maximum index is given. You can use this value, for example, to always select the last entry of a changing drop down list.
Syntax
int ret_code = iimPlay ( String macro [, int timeout] )
Parameters
- String macro
- Either the macro's filename without the extension or a string holding macro commands
- int timeout
- The optional timeout value. If the command is not completed during this time span, the Scripting Interface returns a timeout error -2. No extraction data is returned in this case. The default value is 600 seconds. This is the timeout for the overall macro runtime. This value should not be confused with the timeout inside a macro, which is the timeout for a single macro step.
Error Handling
iimPlay returns a detailed error code for every problem encountered. Please see the Scripting Interface Return Codes and the general iMacros Error-Codes, which are transmitted via the iimPlay command back to the calling application.
Examples
Play a macro located in the Macros\ directory of your iMacros installation (Visual Basic Script example):
Dim imacros, iret Set imacros = CreateObject("imacros") iret = imacros.iimInit() iret = imacros.iimPlay("mymacro")
Play some on-the-fly generated code (Visual Basic Script example):
Dim imacros, iret, mycode, myURL myURL = "http://www.iopus.com" mycode = "URL GOTO=" + myURL + vbNewLine myode = mycode + "TAG POS=1 TYPE=FONT ATTR=TXT:<SP><SP>Online<SP>Store" Set imacros = CreateObject("imacros") iret = imacros.iimInit() iret = imacros.iimPlay("CODE:" + mycode)
Firefox
In the iMacros for Firefox built-in Javascript Scripting Interface you have the option to add the relative path to the iimPlay command. Example: If your Javascript (JS) file is in the main directory, but the macros are in the "test1" subdirectory, then please use iimPlay ("test1/yourmacro"). (Note: This feature will be added to the general Scripting Interface in the near future, too.)