As stated in the title, im trying to have imacros detect when the current url has changed and execute a command when this happens, else keep refreshing the page until the link does change. I am running the imacros add on in firefox. My current code looks like this:
var macro;
macro ="CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_STEP 1" + "\n"
macro += "TAG POS=1 TYPE=A ATTR=TXT:*Some Text*" + "\n";
macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n";
macro += "REFRESH" + "\n";
for (var i=0;i<=50;i++) {
iimPlay(macro);
var link=iimGetLastExtract();
iimSet("LINK",link)
if ("LINK"= ("Some URL"))
{
break;
}
}
In the first part, the code will press on a certain text if it is present on the page, this works fine. My problem comes in during the if statement. I cant figure out how to compare the extracted link and a certain other link. I want the loop to break if the extracted link and the certain link are the same. I am very new to both Java and Imacros so any help would be greatly appreciated!
IMACROS execute a command once current link changes?
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
Re: IMACROS execute a command once current link changes?
(F)CIM...! (Read my Sig...)Sidr21 wrote:As stated in the title, im trying to have imacros detect when the current url has changed and execute a command when this happens, else keep refreshing the page until the link does change. I am running the imacros add on in firefox. My current code looks like this:
In the first part, the code will press on a certain text if it is present on the page, this works fine. My problem comes in during the if statement. I cant figure out how to compare the extracted link and a certain other link. I want the loop to break if the extracted link and the certain link are the same. I am very new to both Java and Imacros so any help would be greatly appreciated!Code: Select all
var macro; macro ="CODE:"; macro += "SET !ERRORIGNORE YES" + "\n"; macro += "SET !TIMEOUT_STEP 1" + "\n" macro += "TAG POS=1 TYPE=A ATTR=TXT:*Some Text*" + "\n"; macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n"; macro += "REFRESH" + "\n"; for (var i=0;i<=50;i++) { iimPlay(macro); var link=iimGetLastExtract(); iimSet("LINK",link) if ("LINK"= ("Some URL")) { break; } }
'iimSet()' is for passing a Var from your main '.js' Script to (inside) your '.iim', you don't need it as you are still in the '.js' for your 'IF' Comparison...
And, hum..., you didn't really need a '.js' Script if you simply want to abort your Script once the Cond. has been met, it could easily be done in pure '.iim' with 'MacroError()'...
>
+Parallel Thread on SOF:
- How to make IMACROS execute a command when the current link changes?
(No Replies yet...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- thecoder2012
- Posts: 446
- Joined: Sat Aug 15, 2015 5:14 pm
- Location: Internet
- Contact:
Re: IMACROS execute a command once current link changes?
Example without your errors:
Code: Select all
var macro;
macro ="CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_STEP 1" + "\n"
macro += "TAG POS=1 TYPE=A ATTR=TXT:*Some Text*" + "\n";
macro += "ADD !EXTRACT {{!URLCURRENT}}" + "\n";
macro += "REFRESH" + "\n";
for (var i=0;i<=50;i++) {
iimPlay(macro);
var link=iimGetLastExtract();
if(link == "Some URL"){
break;
}
}
Java? It's Javascript!Sidr21 wrote:I am very new to both Java and Imacros so any help would be greatly appreciated!
Join 9kw.eu Captcha Service now and let your iMacros continue downloads and scripts while you sleep. - Custom iMacros? Contact me!