set random wait time between 50-60 seconds

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++.

Moderator: iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

set random wait time between 50-60 seconds

by sephi0225 on Sat Apr 18, 2009 3:23 pm

on imacros scripting edition how do you set a wait time to be random between to times , like between 50 and 60 seconds , so it will be like

54
58
50
56
59
51

?? how i do this ?
sephi0225
 
Posts: 1
Joined: Sat Apr 18, 2009 3:19 pm

Re: set random wait time between 50-60 seconds

by Tech Support on Sun Apr 19, 2009 12:20 pm

Please see this example: http://wiki.imacros.net/Random-Numbers.vbs

In your case the script simply needs to create a random number and pass it to the browser:

set iim1= CreateObject ("imacros")
iret = iim1.iimInit

'Initialize the Rnd function
Randomize
'Create random number between 0...10 and add it to 50
rn = 50+cint (rnd()*11)
iret = iim1.iimSet("mynumber", cstr(rn))
'Run the macro
iret = iim1.iimPlay("macro")

---
and in the macro you use
WAIT SECONDS={{mynumber}}
User avatar
Tech Support
 
Posts: 4988
Joined: Tue Sep 20, 2005 12:25 pm

Re: set random wait time between 50-60 seconds

by servet on Sat Jun 20, 2009 1:16 pm

excuse me, but can you explain me a thing?
I use imacros for firefox

Tech Support wrote:and in the macro you use
WAIT SECONDS={{mynumber}}


this is clear:
I insert this line in my macro file mymacrofile.ims

but what is the name of the file who contain the random "code"?
where do I insert this "code"?

Tech Support wrote:Please see this example: http://wiki.imacros.net/Random-Numbers.vbs

In your case the script simply needs to create a random number and pass it to the browser:

set iim1= CreateObject ("imacros")
iret = iim1.iimInit

'Initialize the Rnd function
Randomize
'Create random number between 0...10 and add it to 50
rn = 50+cint (rnd()*11)
iret = iim1.iimSet("mynumber", cstr(rn))
'Run the macro
iret = iim1.iimPlay("macro")
servet
 
Posts: 4
Joined: Mon Aug 18, 2008 8:47 am

Re: set random wait time between 50-60 seconds

by ijuvwe on Fri Jan 07, 2011 12:02 am

servet wrote:excuse me, but can you explain me a thing?
I use imacros for firefox

Tech Support wrote:and in the macro you use
WAIT SECONDS={{mynumber}}


this is clear:
I insert this line in my macro file mymacrofile.ims

but what is the name of the file who contain the random "code"?
where do I insert this "code"?

Tech Support wrote:Please see this example: http://wiki.imacros.net/Random-Numbers.vbs

In your case the script simply needs to create a random number and pass it to the browser:

set iim1= CreateObject ("imacros")
iret = iim1.iimInit

'Initialize the Rnd function
Randomize
'Create random number between 0...10 and add it to 50
rn = 50+cint (rnd()*11)
iret = iim1.iimSet("mynumber", cstr(rn))
'Run the macro
iret = iim1.iimPlay("macro")


I'm still waiting for a clear answer to the above post :?: Tried figuring out by reading parts to wiki but it seems like a riddle
ijuvwe
 
Posts: 2
Joined: Thu Jan 06, 2011 11:57 pm

Re: set random wait time between 50-60 seconds

by Tech Support on Fri Jan 07, 2011 4:39 am

The create random number script code is here: http://wiki.imacros.net/Random-Numbers.vbs

It is for use with the iMacros Scripting Interface. However, you can also create such a script in Javascript inside Firefox: http://wiki.imacros.net/iMacros_for_Fir ... _Interface - if you do this, it would be great if you can post your solution here!
User avatar
Tech Support
 
Posts: 4988
Joined: Tue Sep 20, 2005 12:25 pm

Re: set random wait time between 50-60 seconds

by ijuvwe on Fri Jan 07, 2011 3:13 pm

Tech Support wrote:The create random number script code is here: http://wiki.imacros.net/Random-Numbers.vbs

It is for use with the iMacros Scripting Interface. However, you can also create such a script in Javascript inside Firefox: http://wiki.imacros.net/iMacros_for_Fir ... _Interface - if you do this, it would be great if you can post your solution here!


but what do I save the random "code" as?(a *.vbs or *.js??) & Where do I insert this file? I'm on iMacros scripting edition for IE7

EDIT: How exactly do you make the random code script and macro work together, in baby steps so I can understand
ijuvwe
 
Posts: 2
Joined: Thu Jan 06, 2011 11:57 pm

Re: set random wait time between 50-60 seconds

by Marzani on Thu Sep 29, 2011 4:36 am

Hello,

I also have this problem and did not understand how to solve.
Do I have to save the tech support's script as another file that starts the macro?

I need a random number between 0 and 1, so I tried

Code: Select all
<script language="JavaScript">setTimeout(Math.random(););</script>


:cry: - didn't work - and

Code: Select all
wait seconds=Math.random();


:cry: - also didn't work.

Can anybody explain if the script is used outside the macro in a different file or in an inside part?
Or maybe a complete different solution?
Pleeease give me details. :)

Kisses to our script gurus ;)
Marzani
Marzani
 
Posts: 1
Joined: Thu Sep 29, 2011 4:18 am

Re: set random wait time between 50-60 seconds

by Tech Support on Fri Sep 30, 2011 2:57 pm

Please use the new iMacros V7.5 Beta - here we have the new EVAL command that makes creating random values of all kinds super easy:

Code: Select all
SET !VAR1 EVAL("var randomNumber=Math.floor(Math.random()*10 + 50); randomNumber;")
URL GOTO=http://www.iopus.com
' waits 50 to 60 seconds
WAIT SECONDS={{!VAR1}}
User avatar
Tech Support
 
Posts: 4988
Joined: Tue Sep 20, 2005 12:25 pm

Re: set random wait time between 50-60 seconds

by juandante on Wed Nov 09, 2011 4:01 pm

Hello, and what about random Direct Screen clicks on v7.5 ?

I would like to DS click on links from 10 to 10 pixels until pixel 100 so pixel 10,20,...100

In other words, can DS command be used with a variable in this way :

SET !RANDVAR EVAL("var randomNumber=Math.floor(Math.random()*100); randomNumber;")
DS CMD=CLICK X=RANDVAR Y=100 CONTENT=

Is this possible ?

Also, I would like on the next Imacros those commands :

test command :

IF... THEN
repeat/go to line command :

GOTO LINE

math commands :

/ * + -
Is this possible too ?
juandante
 
Posts: 9
Joined: Wed Nov 09, 2011 3:40 pm

Re: set random wait time between 50-60 seconds

by Tech Support on Wed Nov 09, 2011 4:11 pm

Everything you can do inside the Javascript "eval" function is possible:
SET !RANDVAR EVAL("var randomNumber=Math.floor(Math.random()*100); randomNumber;")
DS CMD=CLICK X=RANDVAR Y=100 CONTENT=
Is this possible ?

Yes

IF... THEN
repeat/go to line command :
GOTO LINE

Not via EVAL, but via scripting interface: http://wiki.imacros.net/FAQ#Q:_Are_ther ... anguage.3F

math commands :
/ * + -
Is this possible too ?

Yes
User avatar
Tech Support
 
Posts: 4988
Joined: Tue Sep 20, 2005 12:25 pm

Re: set random wait time between 50-60 seconds

by juandante on Thu Nov 10, 2011 8:51 pm

Great, but as I'm not good at javascript I would just like to see "random" as a native command in Imacros script, but this javascript code will solve my problem.
I suggest something like :

SET !RANDOM=100 (just like TIMEOUT)

Then someone can use RANDOM word everywhere and it will choose a number between 0-100

Anyway thanks :D
juandante
 
Posts: 9
Joined: Wed Nov 09, 2011 3:40 pm

Re: set random wait time between 50-60 seconds

by Bicgatepc02 on Mon Jan 21, 2013 10:26 pm

Works without colon! But still...what about this "show my ip" command :wink:
Bicgatepc02
 
Posts: 3
Joined: Sat Jan 19, 2013 3:27 am


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: Baidu [Spider] and 0 guests

Website Monitoring