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
Difference between revisions of "send-macro-code.vbs"
(jAhqgQiwMImMgqbbZrH) |
|||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | + | Instead of having the script call a locally saved macro, it can also "send" macro code directly to an iMacros instance. | |
+ | |||
+ | Important: Each iimPlay run resets all settings and value from the previous iimPlay run. This means that you should not use one iimPlay per line, but first concatenate all commands and then send them to iMacros via the iimPlay command (as shown in this example). The browser context is preserved between different iimPlay, so one macro can continue where the previous one stopped. '''Only''' iMacros internal settings ([[SET]] command) are reset between different iimPlay. | ||
+ | |||
+ | Tip: To convert text macros (iim files) into inline code use the [[Editor#Code_Generator|iMacros Editor Code Generator feature]]. | ||
+ | |||
+ | |||
+ | <nowiki> | ||
+ | ' iMacros Send-Macro-Code Script | ||
+ | ' (c) 2008-2015 iOpus/Ipswitch Inc. | ||
+ | |||
+ | Option Explicit | ||
+ | Dim iim1, iret | ||
+ | |||
+ | MsgBox ("This example script uses NO macros, but sends the macro code directly.") | ||
+ | |||
+ | set iim1= CreateObject ("imacros") | ||
+ | iret = iim1.iimOpen("") | ||
+ | |||
+ | Dim MyMacroCode | ||
+ | |||
+ | MyMacroCode = "TAB T=1" + vbNewLine | ||
+ | MyMacroCode = MyMacroCode+"TAB CLOSEALLOTHERS" + vbNewLine | ||
+ | MyMacroCode = MyMacroCode+"URL GOTO=http://imacros.net" + vbNewLine | ||
+ | MyMacroCode = MyMacroCode+"URL GOTO=http://forum.imacros.net" | ||
+ | |||
+ | 'Tip: Use the iMacros Editor Code Generator feature | ||
+ | 'to convert your iMacros macros into some scripting/programming language code. | ||
+ | |||
+ | iret = iim1.iimDisplay("Start demo") | ||
+ | |||
+ | 'Run the first macro | ||
+ | iret = iim1.iimPlayCode(MyMacroCode) | ||
+ | if iret < 0 Then | ||
+ | MsgBox "Macro#1: Error Code: "+cstr(iret) + VbCrLf + "Error Text: "+iim1. iimGetErrorText() | ||
+ | End If | ||
+ | |||
+ | 'Run the second macro (one line only) | ||
+ | iret = iim1.iimPlayCode("URL GOTO=http://www.alertfox.com") | ||
+ | If iret < 0 Then | ||
+ | MsgBox "Macro#2: Error Code: "+cstr(iret) + VbCrLf + "Error Text: "+iim1. iimGetErrorText() | ||
+ | End If | ||
+ | |||
+ | iret = iim1.iimDisplay("Script completed.") | ||
+ | |||
+ | MsgBox "Close iMacros browser" | ||
+ | |||
+ | iret = iim1.iimClose | ||
+ | WScript.Quit(iret) | ||
+ | </nowiki> |
Revision as of 18:15, 27 May 2015
Instead of having the script call a locally saved macro, it can also "send" macro code directly to an iMacros instance.
Important: Each iimPlay run resets all settings and value from the previous iimPlay run. This means that you should not use one iimPlay per line, but first concatenate all commands and then send them to iMacros via the iimPlay command (as shown in this example). The browser context is preserved between different iimPlay, so one macro can continue where the previous one stopped. Only iMacros internal settings (SET command) are reset between different iimPlay.
Tip: To convert text macros (iim files) into inline code use the iMacros Editor Code Generator feature.
' iMacros Send-Macro-Code Script ' (c) 2008-2015 iOpus/Ipswitch Inc. Option Explicit Dim iim1, iret MsgBox ("This example script uses NO macros, but sends the macro code directly.") set iim1= CreateObject ("imacros") iret = iim1.iimOpen("") Dim MyMacroCode MyMacroCode = "TAB T=1" + vbNewLine MyMacroCode = MyMacroCode+"TAB CLOSEALLOTHERS" + vbNewLine MyMacroCode = MyMacroCode+"URL GOTO=http://imacros.net" + vbNewLine MyMacroCode = MyMacroCode+"URL GOTO=http://forum.imacros.net" 'Tip: Use the iMacros Editor Code Generator feature 'to convert your iMacros macros into some scripting/programming language code. iret = iim1.iimDisplay("Start demo") 'Run the first macro iret = iim1.iimPlayCode(MyMacroCode) if iret < 0 Then MsgBox "Macro#1: Error Code: "+cstr(iret) + VbCrLf + "Error Text: "+iim1. iimGetErrorText() End If 'Run the second macro (one line only) iret = iim1.iimPlayCode("URL GOTO=http://www.alertfox.com") If iret < 0 Then MsgBox "Macro#2: Error Code: "+cstr(iret) + VbCrLf + "Error Text: "+iim1. iimGetErrorText() End If iret = iim1.iimDisplay("Script completed.") MsgBox "Close iMacros browser" iret = iim1.iimClose WScript.Quit(iret)