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++.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
sephi0225
Posts: 1
Joined: Sat Apr 18, 2009 10:19 pm

set random wait time between 50-60 seconds

Post by sephi0225 » Sat Apr 18, 2009 10: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 ?
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: set random wait time between 50-60 seconds

Post by Tech Support » Sun Apr 19, 2009 7: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}}
servet
Posts: 4
Joined: Mon Aug 18, 2008 3:47 pm

Re: set random wait time between 50-60 seconds

Post by servet » Sat Jun 20, 2009 8: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")
ijuvwe
Posts: 2
Joined: Fri Jan 07, 2011 6:57 am

Re: set random wait time between 50-60 seconds

Post by ijuvwe » Fri Jan 07, 2011 7: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
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: set random wait time between 50-60 seconds

Post by Tech Support » Fri Jan 07, 2011 11: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!
ijuvwe
Posts: 2
Joined: Fri Jan 07, 2011 6:57 am

Re: set random wait time between 50-60 seconds

Post by ijuvwe » Fri Jan 07, 2011 10: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
Marzani
Posts: 1
Joined: Thu Sep 29, 2011 11:18 am

Re: set random wait time between 50-60 seconds

Post by Marzani » Thu Sep 29, 2011 11: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
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: set random wait time between 50-60 seconds

Post by Tech Support » Fri Sep 30, 2011 9: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}}
juandante
Posts: 9
Joined: Wed Nov 09, 2011 10:40 pm

Re: set random wait time between 50-60 seconds

Post by juandante » Wed Nov 09, 2011 11: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 ?
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: set random wait time between 50-60 seconds

Post by Tech Support » Wed Nov 09, 2011 11: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
juandante
Posts: 9
Joined: Wed Nov 09, 2011 10:40 pm

Re: set random wait time between 50-60 seconds

Post by juandante » Fri Nov 11, 2011 3:51 am

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
Bicgatepc02
Posts: 3
Joined: Sat Jan 19, 2013 10:27 am

Re: set random wait time between 50-60 seconds

Post by Bicgatepc02 » Tue Jan 22, 2013 5:26 am

Works without colon! But still...what about this "show my ip" command :wink:
Post Reply