Discussions and Tech Support specific to the iMacros Firefox add-on.
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
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Tue Nov 10, 2009 12:47 am
Hey alle.
I know there has been made 2 or more threads about this subject before, but i havent been able to figure out what exactly to do.
I have this "code" for a javascript:
Code: Select all
var random_num = Math.floor((Math.random()*300)+60)
But how do i get Imacros (for Firefox) to play it so that the random number is posted as the
time?.
I want to have a random wait time between between 60 and 360sec. Thats why the code up above.
But i just need to know how to implant it in my macro, so that it runs.
-
Hannes, Tech Support
Post
by Hannes, Tech Support » Tue Nov 10, 2009 6:29 am
You can pass values to the macro by using
iimSet().
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Tue Nov 10, 2009 5:03 pm
Hannes, iOpus wrote:You can pass values to the macro by using
iimSet().
Mmh but how? do i have to add something to the javascript?
And how do i get the macro to run the script as the WAIT time?.
-
Hannes, Tech Support
Post
by Hannes, Tech Support » Wed Nov 11, 2009 8:50 am
E.g.
This line in the JS script
may be used in that line of the macro:
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Wed Nov 11, 2009 12:39 pm
Hannes, iOpus wrote:E.g.
This line in the JS script
may be used in that line of the macro:
May i ask, what the "10" is about?
So it would look this?:
Code: Select all
var random_num = Math.floor((Math.random()*300)+60)
iret = iim1.iimSet("myvar", "10")
Or what is missing?
-
ABooth
- Posts: 223
- Joined: Mon Aug 10, 2009 4:25 pm
Post
by ABooth » Wed Nov 11, 2009 4:36 pm
Just do this: -
Code: Select all
iret = iim1.iimSet("myvar", Math.floor((Math.random()*300)+60).toString() );
but give your variable a useful name like "randomWait"
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect
Therefore: You can write powerful macros with iMacros for Firefox. Have a look at
this one
Post feature requests
here. Maybe one day, they'll pin it?
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Wed Nov 11, 2009 9:46 pm
ABooth wrote:Just do this: -
Code: Select all
iret = iim1.iimSet("myvar", Math.floor((Math.random()*300)+60).toString() );
but give your variable a useful name like "randomWait"
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
I tried making a test macro with the info that you wrote:
Code: Select all
VERSION BUILD=6240709 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
URL GOTO=http://www.google.dk/
WAIT SECONDS={{randomWait}}
URL GOTO=www.hot.dk
WAIT SECONDS={{randomWait}}
URL GOTO=www.hotmail.com
WAIT SECONDS={{randomWait}}
WAIT SECONDS=30
and the javascript called
"randomWait.js" looking like this:
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
But it dosnt seem to work proberly.
The randomWait.js is located inside the Macros folder.
-
ABooth
- Posts: 223
- Joined: Mon Aug 10, 2009 4:25 pm
Post
by ABooth » Thu Nov 12, 2009 2:25 pm
SorenC wrote:ABooth wrote:Just do this: -
Code: Select all
iret = iim1.iimSet("myvar", Math.floor((Math.random()*300)+60).toString() );
but give your variable a useful name like "randomWait"
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
I tried making a test macro with the info that you wrote:
Code: Select all
VERSION BUILD=6240709 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
URL GOTO=http://www.google.dk/
WAIT SECONDS={{randomWait}}
URL GOTO=www.hot.dk
WAIT SECONDS={{randomWait}}
URL GOTO=www.hotmail.com
WAIT SECONDS={{randomWait}}
WAIT SECONDS=30
and the javascript called
"randomWait.js" looking like this:
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
But it dosnt seem to work proberly.
The randomWait.js is located inside the Macros folder.
If you're using the .js file from withing Firefox, the iimSet method syntax is as if it is native javascript. If you're using it in the iMacros scripting edition, you need to create an instance of an object. Here's the difference
iMacros scripting edition
Code: Select all
var iim1 = new ActiveXObject("imacros");
var iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
Note we've created an instance of ActiveX object "imacros" and pointed variable iim1 to it, then we make use of the iMacros objects iimSet method, via this iim1 variable.
iMacros for Firefox
Code: Select all
var iret = iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
Note, no reference to an object via variable iim1 (the iim1.iimSet is now just iimSet) The Firefox plugin has a built-in Javascript Interface. It's as if the iimSet command is native javascript.
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect
Therefore: You can write powerful macros with iMacros for Firefox. Have a look at
this one
Post feature requests
here. Maybe one day, they'll pin it?
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Thu Nov 12, 2009 3:51 pm
Hey again.
I've just tried the :
Code: Select all
var iret = iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
but it dosnt seem to do what i want it to do. When IMacros gets to this part:
it just skips over it without running the javascript. i have renamed the javascript file to "randomWait.js", but still no results.
-
josephconlin
- Posts: 190
- Joined: Wed Aug 06, 2008 2:38 am
Post
by josephconlin » Thu Nov 12, 2009 4:37 pm
ABooth wrote:SorenC wrote:ABooth wrote:Just do this: -
Code: Select all
iret = iim1.iimSet("myvar", Math.floor((Math.random()*300)+60).toString() );
but give your variable a useful name like "randomWait"
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
I tried making a test macro with the info that you wrote:
Code: Select all
VERSION BUILD=6240709 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
URL GOTO=http://www.google.dk/
WAIT SECONDS={{randomWait}}
URL GOTO=www.hot.dk
WAIT SECONDS={{randomWait}}
URL GOTO=www.hotmail.com
WAIT SECONDS={{randomWait}}
WAIT SECONDS=30
and the javascript called
"randomWait.js" looking like this:
Code: Select all
iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
But it dosnt seem to work proberly.
The randomWait.js is located inside the Macros folder.
If you're using the .js file from withing Firefox, the iimSet method syntax is as if it is native javascript. If you're using it in the iMacros scripting edition, you need to create an instance of an object. Here's the difference
iMacros scripting edition
Code: Select all
var iim1 = new ActiveXObject("imacros");
var iret = iim1.iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
Note we've created an instance of ActiveX object "imacros" and pointed variable iim1 to it, then we make use of the iMacros objects iimSet method, via this iim1 variable.
iMacros for Firefox
Code: Select all
var iret = iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
Note, no reference to an object via variable iim1 (the iim1.iimSet is now just iimSet) The Firefox plugin has a built-in Javascript Interface. It's as if the iimSet command is native javascript.
I'm going to pretend that your macro (the .iim file) is called test.iim. You can replace the word test with whatever your macro is actually called.
randomWait.js
Code: Select all
iret = iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
iret = iimPlay("test.iim");
iimSet sets the value of a variable that you intend to pass to a macro that you want the javascript to execute. iimPlay actually runs the macro from javascript.
To run the macro, click on randomWait.js and then click the Play button. You don't have to execute the .iim macro with the Play button, because the javascript macro is starting it for you. If you run the .iim macro by itself, it will fail because it doesn't know what the value of randomWait is (in your case, the failure was by not waiting at all).
You cannot write a .iim macro that calls a .js macro or function. You can only write .js macros that can call .iim macros. If you are using a .js macro, you have to run it by clicking on the .js macro and clicking the Play button.
Hope this helps.
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Thu Nov 12, 2009 4:43 pm
josephconlin wrote:
I'm going to pretend that your macro (the .iim file) is called test.iim. You can replace the word test with whatever your macro is actually called.
randomWait.js
Code: Select all
iret = iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
iret = iimPlay("test.iim");
iimSet sets the value of a variable that you intend to pass to a macro that you want the javascript to execute. iimPlay actually runs the macro from javascript.
To run the macro, click on randomWait.js and then click the Play button. You don't have to execute the .iim macro with the Play button, because the javascript macro is starting it for you. If you run the .iim macro by itself, it will fail because it doesn't know what the value of randomWait is (in your case, the failure was by not waiting at all).
You cannot write a .iim macro that calls a .js macro or function. You can only write .js macros that can call .iim macros. If you are using a .js macro, you have to run it by clicking on the .js macro and clicking the Play button.
Hope this helps.
See now that works.
Thank you very much for the extra assistance for this issue. I was about to get very bald, because i couldnt figure out the problem with it.
-
ABooth
- Posts: 223
- Joined: Mon Aug 10, 2009 4:25 pm
Post
by ABooth » Thu Nov 12, 2009 6:40 pm
SorenC wrote:Hey again.
I've just tried the :
Code: Select all
var iret = iimSet("randomWait", Math.floor((Math.random()*300)+60).toString() );
but it dosnt seem to do what i want it to do. When IMacros gets to this part:
it just skips over it without running the javascript. i have renamed the javascript file to "randomWait.js", but still no results.
I didn't realize you weren't executing properly.
FYI:
- The javascript executes the macro, not the other way around. You run the .js file in the firefox plugin and it runs the iim file.
- What the javascript is doing is preparing the variable for the next iimPlay execution
- You should then execute the iimPlay to actually run the macro.
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect
Therefore: You can write powerful macros with iMacros for Firefox. Have a look at
this one
Post feature requests
here. Maybe one day, they'll pin it?
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Fri Nov 13, 2009 9:38 am
Hey guys.
Thanx for your assistance.
Now i have another problem.
It seems like the randomWait.js only runs once. It goes through the macro and then stops after executing the macro. But i need it to run X number of times. I know there is some looping code for JS, that i need to use.
But how do i implament it into the current javascript that i have?
Code: Select all
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("randomWait.iim");
I have tried this:
Code: Select all
var i=1;
for (i=1;i<=3;i++)
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("test.iim");
But it dosnt seem to do the trick.
-
josephconlin
- Posts: 190
- Joined: Wed Aug 06, 2008 2:38 am
Post
by josephconlin » Fri Nov 13, 2009 4:47 pm
SorenC wrote:Hey guys.
Thanx for your assistance.
Now i have another problem.
It seems like the randomWait.js only runs once. It goes through the macro and then stops after executing the macro. But i need it to run X number of times. I know there is some looping code for JS, that i need to use.
But how do i implament it into the current javascript that i have?
Code: Select all
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("randomWait.iim");
I have tried this:
Code: Select all
var i=1;
for (i=1;i<=3;i++)
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("test.iim");
But it dosnt seem to do the trick.
You need curly braces ( { } ) around the part you want to be looped. Try this.
Code: Select all
var i=1;
for (i=1;i<=3;i++)
{
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("test.iim");
}
Without the curly braces, your command is interpreted as whatever is on this single line gets looped, so your loop just counts from 1 to 3 and then moves on to the iimSet line. You want the iimSet and the iimPlay parts to be looped over, so you have to enclose them inside the curly braces.
Hope this helps.
-
SorenC
- Posts: 36
- Joined: Wed Oct 28, 2009 4:33 pm
Post
by SorenC » Fri Nov 13, 2009 5:05 pm
josephconlin wrote:SorenC wrote:Hey guys.
Thanx for your assistance.
Now i have another problem.
It seems like the randomWait.js only runs once. It goes through the macro and then stops after executing the macro. But i need it to run X number of times. I know there is some looping code for JS, that i need to use.
But how do i implament it into the current javascript that i have?
Code: Select all
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("randomWait.iim");
I have tried this:
Code: Select all
var i=1;
for (i=1;i<=3;i++)
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("test.iim");
But it dosnt seem to do the trick.
You need curly braces ( { } ) around the part you want to be looped. Try this.
Code: Select all
var i=1;
for (i=1;i<=3;i++)
{
iret = iimSet("randomWait", Math.floor((Math.random()*160)+100).toString() );
iret = iimPlay("test.iim");
}
Without the curly braces, your command is interpreted as whatever is on this single line gets looped, so your loop just counts from 1 to 3 and then moves on to the iimSet line. You want the iimSet and the iimPlay parts to be looped over, so you have to enclose them inside the curly braces.
Hope this helps.
I knew i was forgetting something.
That did the trick.
Thank you very much. To all that has helped in this thread. I really appreciate it .. Kudos til Iopus for making Imacros for FF.