connect-to-fx.vbs

From iMacros

Jump to: navigation, search

This example script connects to an instance of Mozilla Firefox with iMacros for Firefox installed. If it can not find one it starts Firefox. It calls the macro Demo-Frame.iim.

Visual Basic Script:

 MsgBox ("This example script opens an instance of Firefox. For this script to work you need to have iMacros for *Firefox* or later installed.")
 set iim1= CreateObject ("iMacros")
 i = iim1.iimInit ("-fx", false)
 if i<0 then
   msgbox "Could not connect to a FIREFOX web browser."
 end if
 i = iim1.iimPlay("demo-frame", 60)
 if i<0 then
   s = iim1.iimGetLastError()
   msgbox "The Scripting Interface returned error code: "+cstr(i)
 end if
 msgbox "Press OK to close Firefox"
 i = iim1.iimExit
 WScript.Quit(0)


Macro Code for Demo-Frame:

 VERSION BUILD=4201129     
 TAB T=1     
 TAB CLOSEALLOTHERS     
 URL GOTO=http://www.iopus.com/imacros/demo/v5/frames/index.htm         
 'Slow down so user can see what we are doing...
 SET !REPLAYSPEED MEDIUM
 FRAME F=2     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f2 ATTR=NAME:T1 CONTENT=F2 
 FRAME F=3     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f3 ATTR=NAME:T1 CONTENT=F3 
 FRAME F=4     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f3 ATTR=NAME:T1 CONTENT=F4 
 FRAME F=5     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f5 ATTR=NAME:T1 CONTENT=F5 
 FRAME F=6     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f6 ATTR=NAME:T1 CONTENT=F6 
 FRAME F=7     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f6 ATTR=NAME:T1 CONTENT=F7 
 FRAME F=8     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f8 ATTR=NAME:T1 CONTENT=F8 
 WAIT SECONDS=1    
 FRAME F=7     
 TAG POS=1 TYPE=A ATTR=HREF:http://www.iopus.com/imacros/demo/v5/frames/subframe.htm   
 FRAME F=8     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:sf1 ATTR=NAME:T1 CONTENT=More<SP>frames 
 FRAME F=9     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:sf2 ATTR=NAME:T1 CONTENT=One<SP>more... 
 FRAME F=10     
 TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:sf3 ATTR=NAME:T1 CONTENT=Macro<SP>completed