Passing variable to iMacro from VBS

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Marcia, iOpus, Hannes, iOpus, Tech Support, Tom, iOpus

Passing variable to iMacro from VBS

Postby jcretief on Fri Oct 30, 2009 2:22 am

Hi,

I’m trying to pass a value to a variable in iMacro from a VBS script. I’ve used the forum and tried all the examples, but probably doing something wrong. I’ve re-install with the 6.8 version and this did not help.

I’m trying to provide the variable “LOOPNUMBER” with a value. I’ve tested the value before the “SET !DATASOURCE_LINE {{LOOPNUMBER}}” line and the LOOPNUMBER is blank (“”). Which probably means that the value was not passed from the VBS script. I’ve also tried the variable in the iMacro script with and without the prefix character “!”, and still no luck.

Here are the scripts:

VBS
set iim1= CreateObject ("imacros")

i = iim1.iimInit ("-ie")
i = iim1.iimPlay("CUST.I.INIT")

dim intLoop

intLoop = 3

Do Until intLoop = 4

i = iim1.iimSET("-var_LOOPNUMBER", CStr(intLoop))
i = iim1.iimPLAY("CUST.I.50")

intLoop = intLoop + 1

Loop


iMacro
VERSION BUILD=6600525
TAB T=1
TAB CLOSEALLOTHERS
SET !FILESTOPWATCH CUST.I.RESULTS.csv
SET !DATASOURCE CUST.I.CSV
'Number of columns in the CSV file. This must be accurate!
SET !DATASOURCE_COLUMNS 23
'Start at line 2 to skip the header in the file
'Increase the current position in the file with each loop
SET !DATASOURCE_LINE {{LOOPNUMBER}}
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_ContentPlaceHolder1_Text;3;0;35;True;3;; CONTENT={{!COL6}}
WAIT SECONDS=1
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:aspnetForm ATTR=ID:ctl00_ContentPlaceHolder1_Text;4;0;35;True;4;; CONTENT={{!COL7}}


I’ll really appreciate if someone could assist with a solution.

Regards,
JC
jcretief
 
Posts: 2
Joined: Fri Oct 30, 2009 12:20 am

Re: Passing variable to iMacro from VBS

Postby Hannes, iOpus on Mon Nov 02, 2009 12:47 am

You should use iimSet() without the "-var_":
Code: Select all
i = iim1.iimSET("LOOPNUMBER", CStr(intLoop))

Cf. http://wiki.imacros.net/iimSet%28%29
Hannes, iOpus Support
Hannes, iOpus
 
Posts: 1838
Joined: Thu Sep 21, 2006 6:27 am

Re: Passing variable to iMacro from VBS

Postby jcretief on Mon Nov 02, 2009 3:20 am

Hi,

Thanks for the reply.

I've also tried that before and also not working.

Any other ideas?

Thanks

JC
jcretief
 
Posts: 2
Joined: Fri Oct 30, 2009 12:20 am

Re: Passing variable to iMacro from VBS

Postby Hannes, iOpus on Tue Nov 03, 2009 2:08 am

The following code worked fine for me (running v6.80):

Code: Select all
Dim iim1
set iim1= CreateObject ("imacros")

Dim i
i = iim1.iimInit ("-ie")

dim intLoop
intLoop = 3
Do Until intLoop = 4
   i = iim1.iimSET("LOOPNUMBER", CStr(intLoop))
   i = iim1.iimPLAY("#Current")
   intLoop = intLoop + 1
Loop

Code: Select all
VERSION BUILD=6801021     
TAB T=1     
TAB CLOSEALLOTHERS     
URL GOTO=http://www.google.com/     
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT={{LOOPNUMBER}}
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG 
Hannes, iOpus Support
Hannes, iOpus
 
Posts: 1838
Joined: Thu Sep 21, 2006 6:27 am


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: Google [Bot] and 1 guest