IF...else...condition, please help
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
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
IF...else...condition, please help
Ok guys i have two macros i want to play in separate conditions.
There is a game i play that from time to time it refresh its own page with a picture i have to click so to continue playing.
I have make a macro that i need to be executed and one that is been executed when the picture is been placed on so to continue.
So in few words i want something like this.
1)I am in the page.
2)I execute macro1
3)IF the page with the picture appears to execute macro2(i can recognize it with the URL of the picture that is always the same).
So in other words i want a condition that will look for URL of the picture IN the page and IF it finds it to execute macro2 and then..
4)Go back to execute macro1.2nd time, then again when it ends to look for IF condition above and if not back to macro1 and so on for 100 times.
All those in a loop of like 100 times.(i noticed in a .js file he loop button do not work but i know there is loop code for javascript...)
Is that possible and if yes can anyone write me the code here as i have no idea of javascript.
There is a game i play that from time to time it refresh its own page with a picture i have to click so to continue playing.
I have make a macro that i need to be executed and one that is been executed when the picture is been placed on so to continue.
So in few words i want something like this.
1)I am in the page.
2)I execute macro1
3)IF the page with the picture appears to execute macro2(i can recognize it with the URL of the picture that is always the same).
So in other words i want a condition that will look for URL of the picture IN the page and IF it finds it to execute macro2 and then..
4)Go back to execute macro1.2nd time, then again when it ends to look for IF condition above and if not back to macro1 and so on for 100 times.
All those in a loop of like 100 times.(i noticed in a .js file he loop button do not work but i know there is loop code for javascript...)
Is that possible and if yes can anyone write me the code here as i have no idea of javascript.
Re: IF...else...condition, please help
As i am waiting here for a reply, look what i got.
js Code
But the problem is it gives me all the time negative even when the URL(image) is there.
What i am doing wrong?
Thank you.
js Code
Code: Select all
var i;
var s;
for(k=0; k<100; k++) {
s = iimGetLastExtract();
i = s.indexOf ("http://myimageurlhere");
if (i < 0) {
iimPlay ("Google");
} else {
iimPlay ("Gmail");
}
}
But the problem is it gives me all the time negative even when the URL(image) is there.
What i am doing wrong?
Thank you.
Re: IF...else...condition, please help
now i realized that i have to write the search lines and set the i as a javascript.
Is anyone able to do that for me?
All i need is to nclude in javascript a search on the page of a TXT.
Like search of "Hello" if there is and then set that as i as a result. Postitive if it finds it and negative if not so to continue my loop.
-------------------------------------------------------
EDIT:
As i see i need something like this.
js Code
Is anyone able to do that for me?
All i need is to nclude in javascript a search on the page of a TXT.
Like search of "Hello" if there is and then set that as i as a result. Postitive if it finds it and negative if not so to continue my loop.
-------------------------------------------------------
EDIT:
As i see i need something like this.
js Code
Code: Select all
var i;
for(k=0; k<100; k++) {
search the page i run the script for a text(for example "Hello world"), using javascript(i dont know how...)<--- to this i need help
And then set the result i ll get as i<--- to this i need help
so to continue with the if.....else.... statement here.
Please guys help me here?
if (i < 0) {
iimPlay ("Google");
} else {
iimPlay ("Gmail");
}
}
Re: IF...else...condition, please help
Code: Select all
for (var i = 1; i <= 100; i++) {
iimPlay("macro1");
if (iimPlay('CODE: SEARCH SOURCE=TXT:"Hello World!" IGNORE_CASE=YES') < 0) {
iimPlay("macro1");
}
else {
iimPlay("macro2");
}
}
Re: IF...else...condition, please help
First of all thank you in advance.
Now trying this out i realized that always goes to else condition even when the test in in the page source.
Also i want when i press the script to do:
1)the search for the word in source of the page i run it
2)if it find the word to play macro1
3)if it will not find the word to play macro2.
4)do the search again after it finish executing macro1 or macro2 and so on the steps 2 and 3.
5) all that in a loop of 100.
With your code here it executes the macro1 first.(btw i removed it of my code that line "iimPlay("macro1");")
EDIT: I cant stop the code here to run, and it loops the macro1 over and over again without the search after it done...
Now trying this out i realized that always goes to else condition even when the test in in the page source.
Also i want when i press the script to do:
1)the search for the word in source of the page i run it
2)if it find the word to play macro1
3)if it will not find the word to play macro2.
4)do the search again after it finish executing macro1 or macro2 and so on the steps 2 and 3.
5) all that in a loop of 100.
With your code here it executes the macro1 first.(btw i removed it of my code that line "iimPlay("macro1");")
EDIT: I cant stop the code here to run, and it loops the macro1 over and over again without the search after it done...
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: IF...else...condition, please help
Code: Select all
var ret;
for (var i = 1; i <= 100; i++) {
// 1) search for the word in source of the page i run it
ret = iimPlay('CODE:SEARCH SOURCE=TXT:"Hello World!" IGNORE_CASE=YES');
// 2)if it find the word to play macro1
if (ret == 1) { // Text was found
ret = iimPlay("macro1");
}
// 3)if it will not find the word to play macro2
else if (ret != -101) {
ret = iimPlay("macro2");
}
if (ret == -101) { // User clicked the Stop button
break;
}
}
Regards,
Tom, iMacros Support
Tom, iMacros Support
Re: IF...else...condition, please help
Code: Select all
for (var i = 1; i <= 100; i++) {
if (iimPlay('CODE: SEARCH SOURCE=TXT:"Hello World!" IGNORE_CASE=YES') < 0) {
iimPlay("macro1");
}
else {
iimPlay("macro2");
}
}
Tim is it possible to make an if condition here that will check the URL it is?
Like this.
1)Check URL i am in
2)IF URL is this one http://www.URL1.com then continue to the above code.
3)IF URL is anything else but http://www.URL1.com then close the current tab and run the script again.
Thank you in advance.
EDIT. Basically it can be done if there is a way to close all tabs BUT the tab 1 in order.
I mean i have 1,2 tabs opened and some times cause of hanging out the page in tab 2 the script sticks in tab 2 when it has to go back in tab.
Is any way to declare close ALL tabs but tab 1? As they are appearing in my firefox.
OFc if i am to the tab 1 to keep that open as it is.
Thank you in advance.
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: IF...else...condition, please help
You can extract the current URL in your macro with the following command:1)Check URL i am in
2)IF URL is this one http://www.URL1.com then continue to the above code.
3)IF URL is anything else but http://www.URL1.com then close the current tab and run the script again.
Code: Select all
ADD !EXTRACT {{!URLCURRENT}}
Code: Select all
var url = iimGetLastExtract(1);
if (url == "http://www.URL1.com") {
...
}
else {
...
}
Is any way to declare close ALL tabs but tab 1?
Code: Select all
TAB T=1
TAB CLOSEALLOTHERS
http://wiki.imacros.net/!URLCURRENT
http://wiki.imacros.net/iimGetLastExtract()
http://wiki.imacros.net/TAB
Regards,
Tom, iMacros Support
Tom, iMacros Support
Re: IF...else...condition, please help
BOLD.Tom, iOpus wrote:You can extract the current URL in your macro with the following command:1)Check URL i am in
2)IF URL is this one http://www.URL1.com then continue to the above code.
3)IF URL is anything else but http://www.URL1.com then close the current tab and run the script again.
Its same in javascript code as well?Cause i need that in js file as codeCode: Select all
ADD !EXTRACT {{!URLCURRENT}}
Then you can retrieve this value in your script with the following:
thank youCode: Select all
var url = iimGetLastExtract(1); if (url == "http://www.URL1.com") { ... } else { ... }
Is any way to declare close ALL tabs but tab 1?This is closing all tabs but the one i run it.Code: Select all
TAB T=1 TAB CLOSEALLOTHERS
I want to close all tabs but the first one, in any tab i may run the code.
Reference:
http://wiki.imacros.net/!URLCURRENT
http://wiki.imacros.net/iimGetLastExtract()
http://wiki.imacros.net/TAB
Thank you Tom
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: IF...else...condition, please help
I'm not sure this is possible considering the way iMacros for Firefox handles the counting of tabs:I want to close all tabs but the first one, in any tab i may run the code.
http://wiki.imacros.net/TAB#Note
You may have to come up with your own Javascript code to accomplish this.
Regards,
Tom, iMacros Support
Tom, iMacros Support