Random-Numbers.vbs
From iMacros
This script uses the random number functionality of Visual Basic Script to generate and submit randomly chosen words to a website. It calls a macro called Wsh-Random to submit the data.
Option Explicit
Dim iim1, iret
Dim rn, i, keyword
MsgBox ("This example script submits random information to a website")
set iim1= CreateObject ("InternetMacros.iim")
iret = iim1.iimInit
'Run 3 times
for i = 1 to 3
iret = iim1.iimDisplay("Generating number")
'Create random number between 1 and 5
Randomize
rn = cint (rnd()*5 + 1)
iret = iim1.iimDisplay("Number=" + cstr(rn))
select case rn
case 1:
keyword = "Sunshine"
case 2:
keyword = "Snow"
case 3:
keyword = "Rain"
case 4:
keyword = "Wind"
case 5:
keyword = "clouds"
case else:
keyword = "This should not happen"
end select
'Set the variables
iret = iim1.iimSet("-var_mynumber", cstr(rn))
iret = iim1.iimSet("-var_mytext", keyword)
'Run the macro
iret = iim1.iimPlay("wsh-random")
If iret < 0 Then
MsgBox iim1.iimGetLastError()
End If
next
iret = iim1.iimDisplay("The script and macro are completed. Click OK to close the IIM browser and this script.")
iret = iim1.iimExit
WScript.Quit(0)
Macro code for Wsh-Random:
VERSION BUILD=3341216 TAB T=1 TAB CLOSEALLOTHERS URL GOTO=http://www.iopus.com/imacros/demo/v5/f2/automatic-data-entry.asp TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:FNAME CONTENT={{mynumber}} TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:WebDataEntry ATTR=NAME:LNAME CONTENT={{mytext}} TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:WebDataEntry ATTR=NAME:SendButton&&VALUE:Click<SP>to<SP>submit<SP>data
