Imacros & Visual Basic 2008....how do you setup a variable to use in the script?

simpleonlinetest

Regular Member
Joined
Feb 18, 2010
Messages
208
Reaction score
25
I created a simple program that submits urls to social bookmarking sites....catch is that I had to manually edit each macro script to enter the new url so I created a Visual Basic 2008 program to speed things up.

Is it possible to seutp a variable using a text box in VB and then pass that variable into the imacros script?

 
Well, I'm just kinda wingin' this but...

Couldn't you take in the prompt in VB via the InputBox function (i.e. newU.rl = InputBox("Enter the URL: ") then pass that into your VB loop with iret = iim1.iimSet("-var_newU.rl", Cstr(newU.rl))? Then just have a {{newU.rl}} variable somewhere in your macro.
 
I've been trying to get this work where it takes an input from a csv file, which will become a variable, since it will select a row at random... I've been at this for a while, digging through their example scripts (in the imacros help section), but I just can't get it to work.... would greatly appreciate if anyone has a working example of this... I did what aworford1 said but it still isn't working
 
Actually, turns out my problem is something related to reading the .csv.. I got this to work, its from the imacro samples but i put it into .wsf format so you just have to double click it to run (its a windows script file)

You can take this and put into the VB UI if you want, just figured I'd post this here for anyone who is interested:

put this into a text file and save (make sure to click 'save as type < all files' first, then save as "somename.wsf" (just has to be .wsf)

---------------------------------------------

<job id="main">


<script language="VBScript">

Dim iim1, iret
Dim rn, i, keyword

MsgBox ("This example script submits random information to a website")

set iim1= CreateObject ("imacros")
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("mynumber", cstr(rn))
iret = iim1.iimSet("mytext", keyword)

'Run the macro
iret = iim1.iimPlay("reddit-register")
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)


</script>
</job>

-----------------------------------------

Then save this script as reddit-register.iim and import into imacros

-------------------------------------------

VERSION BUILD=6900210
TAB T=1
SET !ERRORIGNORE YES
TAB CLOSEALLOTHERS

SET !DATASOURCE C:\Users\a\Desktop\imacros\Reddit-databases\nnnnnnnn.csv
SET !DATASOURCE_COLUMNS 10

SET !DATASOURCE_LINE {{!LOOP}}

URL GOTO=http://www.reddit.com/
TAG POS=1 TYPE=A ATTR=TXT:register
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://www.reddit.com/post/reg ATTR=ID:user_reg CONTENT={{mynumber}}
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:http://www.reddit.com/post/reg ATTR=ID:email_reg CONTENT={{mytext}}
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:http://www.reddit.com/post/reg ATTR=ID:passwd_reg CONTENT=test
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:http://www.reddit.com/post/reg ATTR=ID:passwd2_reg CONTENT=test
WAIT SECONDS=8

TAG POS=1 TYPE=BUTTON ATTR=TXT:create<SP>account

------------------------------------

When you run the .wsf it will start the imacro script and then put a random number in the first 2 registration fields, just something to play around with and build upon if you want
 
Or do it the easier way. Use a batch replace program to replace the url in each of your files.

Here;s a virustotal analysis of the attached file.

Code:
http://www.virustotal.com/analisis/dbe3ad6be56a8615cf95d5ecbbdc7ce7213926d04de95dc3b4417e7fe757fc36-1265935483
 

Attachments

Or do it the easier way. Use a batch replace program to replace the url in each of your files.

Here;s a virustotal analysis of the attached file.

Code:
http://www.virustotal.com/analisis/dbe3ad6be56a8615cf95d5ecbbdc7ce7213926d04de95dc3b4417e7fe757fc36-1265935483

well, I'm not sure I understood exactly what the OP wanted to do, but it sounds like he could just use a .csv file to loop through urls which is natively supported by imacros, anyways, using variables will help in the long run as it allows for more advanced functionality
 
well, I'm not sure I understood exactly what the OP wanted to do, but it sounds like he could just use a .csv file to loop through urls which is natively supported by imacros, anyways, using variables will help in the long run as it allows for more advanced functionality

Ofcourse using a csv would be the best way. However, from what I seem to understand, the OP has a lot of macros that he wants to edit the code of. Anyhow, he'll have the best bet to batch replace code snippets to include the csv.
 
Back
Top