Page 1 of 1

Looping through array of characters (VBS)

Posted: Mon Sep 29, 2008 9:13 am
by Hannes, Tech Support
If a web form needs to be queried for "a", "b", "c", ..., the following VBS script will show give you all the necessary steps:

Code: Select all

Option Explicit

'initiate iMacros instance 
Dim iim1, iret
set iim1 = CreateObject ("imacros")
iret = iim1.iimInit()

Dim myArray, recentChar, macro
myArray=Array("a","b","c","d","e") ' may need to be completed :-)

for each recentChar in myArray
	macro = "CODE:"
	macro = macro + "TAB T=1     " + vbNewLine
	macro = macro + "TAB CLOSEALLOTHERS     " + vbNewLine
	macro = macro + "URL GOTO=http://www.google.com/     " + vbNewLine
	'######
	' here we use the loop's character directly in the macro
	'######
	macro = macro + "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT=" + Cstr(recentChar) + vbNewLine
	macro = macro + "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG  "
	iret = iim1.iimPlay(macro)
next