connect-to-ie.vbs

From iMacros

Jump to: navigation, search

This example script connects to an already open instance of Internet Explorer with an active (open) iMacros Add-On. If it can not find one it starts Internet Explorer. It calls the macro Demo-Frames.

Technically this script is exactly the same as a script that uses the iMacros Browser, but it invokes Internet Explorer with iimInit ("-ie").

Visual Basic Script:

 Option Explicit
 Dim iim1, iret
  
 set iim1= CreateObject ("imacros")
 iret = iim1.iimInit ("-ie", FALSE)
 
 if iret < 0 then MsgBox ("For this example to work you must make sure that the iMacros add-on is **open** (visible).")
 
 iret = iim1.iimDisplay("Start demo")
   
 'Run the first macro
 iret = iim1.iimPlay("Demo-Frames", 30)
 if iret < 0 Then
    MsgBox  "Error in Macro#1: "+ cstr (iret) +iim1.iimGetLastError()
 End If
 
 iret = iim1.iimDisplay("Script completed.")
 
 MsgBox "Close Internet Explorer"
 
 iret = iim1.iimExit(1)
 if iret < 0 Then
    MsgBox  "Error in Macro#1: "+ cstr (iret) +iim1.iimGetLastError()
 End If
 WScript.Quit(0)