Example Windows Scripting Host
Top  Previous  Next

Related example scripts: Examples\Windows Scripting Host

The Window Scripting Host interprets programs written in a language called Visual Basic Script, which is related to Visual Basic and the macro languages of the Microsoft Office package (VBA). Visual Basic Script files can be created and edited with any editor (e.g. Notepad), are executed by double-clicking them and have the file ending .vbs.

The iMacros Browser is controlled by the Visual Basic Script by calling commands of the Scripting Interface.

The following example creates an instance of the iMacros Browser, sets some variables and plays a macro. The return value of the macro is then checked for errors. To run this example, copy this text in a file with the ending
.vbs, e.g. test.vbs. After double-clicking the file, iMacros will start in tray mode since in line 4 the command line switch -tray is activated. This means that an iMacros icon will apear in the system tray during replay. You can maximize iMacros by double-clicking this icon.

'initialize Scripting Interface
Set iim1 = CreateObject ("InternetMacros.iim")
i = iim1.iimInit()
 

' setting variables
i = iim1.iimSet("-var1", "Tom Tester")
i = iim1.iimSet("-tray", "")


' displaying message
i = iim1.iimDisplay("This is a test")

' play macro
i = iim1.iimPlay("myfirstmacro"
)

' check success
If i > 0 Then
  s = "Everything OK"
Else
  s = iim1.iimGetLastError()
End If
MsgBox s

' exit iMacros
i = iim1.iimExit()






Page URL http://www.iopus.com/imacros/help/scriptingexamplevbs.htm