Loop script until...
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
Loop script until...
I'm on a website with javascript and i use imacros to click on a certain button, this i solved, easy enough, but i want the script to stop when a number appears and it's a number between to values lets say the script should stop if in a certain zone of the website a number between 1 and 10 should appear is this possible?
Re: Loop script until...
T?hat is going to require a batch list in Javascript. iMacros does not have conditional statements. you are looking at something like this...
This will loop until it is between 1 & 10.
I don't have any way to test the code so let me know how it goes.
Code: Select all
while (extracted >=1<=10)
{
iimPlay("CODE: insert the imacro code for clicking the button here")
iimPlay("CODE: insert iMacros code fro text area you are trting to get the value of here :* EXTRACT=TXT")
extracted = iimGetLastExtract (extracted)
}
This will loop until it is between 1 & 10.
I don't have any way to test the code so let me know how it goes.
Re: Loop script until...
This is my code:
And i get error: "SyntaxError: unknown command: WHILE, line: 1 (Error code: -910)
Code: Select all
while (extracted >=1<=10)
{
iimPlay("CODE: TAB T=1
TAG POS=1 TYPE=IMG ATTR=SRC:button.gif
wait seconds=1")
iimPlay("CODE: Level: :* EXTRACT=TXT")
extracted = iimGetLastExtract (extracted)
}
Re: Loop script until...
Here is my code:
But I get this error:
SyntaxError: missing ) after argument list (Error code: 991)
I'm new to javascript, but i tried adjusting the script but it didn't help.
Code: Select all
while (extracted >=1<=10)
{
iimPlay("CODE: REFRESH")
iimPlay("CODE: TAG POS=1 TYPE=P ATTR=TXT:"Level:<SP>*"* EXTRACT=TXT")
extracted = iimGetLastExtract (extracted)
}
SyntaxError: missing ) after argument list (Error code: 991)
I'm new to javascript, but i tried adjusting the script but it didn't help.
-322126384
Re: Loop script until...
Ok a few different problems her. First you have to define extracted before you go into the while loop (my fault for not putting that in my code). Second, line 4 is a mess and im not exactly sure what you are trying to do. Third, anything in the iimPlay() has to be on one line. Use \n to change lines.
So lets see if this gets us any closer.
now this code is not clicking a button. its just refreshing. Is that what you want? Refreshing is going to be much slower than just pressing a button. Im guessing you are trying to do this.
I don't know what the site looks like so this all kind of a guessing game. To make this a bit easier record a macro where you click the button and then click the number that you are trying to extract. So i can see the specific actions or just send me link to the site.
So lets see if this gets us any closer.
Code: Select all
var extracted = null;
while (extracted >=1<=10)
{
iimPlay("CODE: REFRESH")
iimPlay("CODE: TAG POS=1 TYPE=P ATTR=TXT:Level:* EXTRACT=TXT")
extracted = iimGetLastExtract (extracted)
}
Code: Select all
extracted = null;
while (extracted >=1<=10)
{
iimPlay("CODE: TAB T=1\n TAG POS=1 TYPE=IMG ATTR=SRC:button.gif\n wait seconds=1")
iimPlay("CODE: TAG POS=1 TYPE=P ATTR=TXT:Level:* EXTRACT=TXT")
extracted = iimGetLastExtract (extracted)
}
Re: Loop script until...
The website is: www.pokemonvortex.org and i need a macro for the map part to find legendary pokemons , the macro needs to click on the move button and when it encounters a legendary pokemon should stop , normal pokemon have a level between 8 and 15 and legendary pokemons have a level between 50 and 100, these level are found on the map. So i want this macro to stop the looped clicking of the move button when on screen appears a pokemon with level between 50 and 100.
Re: Loop script until...
I don't have an account so I can't see any of that. Just record a macro where you click the button and then click the number that you are trying to extract and post it and im sure we can figure this out.
Re: Loop script until...
what a coincidence, i am using the same website. here is the recorded macro like you requested
The part where it says arrowup there are 7 other options. it is actually just an image ( ) that navigates your sprite up on the map.
Code: Select all
VERSION BUILD=7300701 RECORDER=FX
TAB T=1
TAG POS=1 TYPE=IMG ATTR=SRC:http://static.pokemonvortex.org/images/maps/arrows/arrowup.gif
TAG POS=1 TYPE=P ATTR=TXT:Level:<SP>13
-322126384
Re: Loop script until...
Ok great, lets try this.
I think we've got it with this one. One of you test it on the site and let me know.
Code: Select all
var pokLevel = null;
while (pokLevel >=50<=100)
{
iimPlay("CODE: TAG POS=1 TYPE=IMG ATTR=SRC:http://static.pokemonvortex.org/images/maps/arrows/arrowup.gif");
iimPlay("CODE: TAG POS=1 TYPE=P ATTR=TXT:Level:* EXTRACT=TXT");
pokLevel = iimGetLastExtract ();
}
alert("Encountered a Legendary Pokemon. Level " + pokLevel);
Re: Loop script until...
In firefox i'm getting the same error as my previous posts.
"SyntaxError: unknown command: WHILE, line: 1 (Error code: -910)
When i try to run this macro in iMacros browser it doesn't do anything i click play and nothing really happens.
"SyntaxError: unknown command: WHILE, line: 1 (Error code: -910)
When i try to run this macro in iMacros browser it doesn't do anything i click play and nothing really happens.
-
- Posts: 3834
- Joined: Mon May 31, 2010 4:59 pm
Re: Loop script until...
Make sure the file is saved as a .js file and not .iim. This is Javascript code and not macro code. The Javascript code is calling the macros via the built-in Javascript scripting interface.ssjmaz wrote:In firefox i'm getting the same error as my previous posts.
"SyntaxError: unknown command: WHILE, line: 1 (Error code: -910)
When i try to run this macro in iMacros browser it doesn't do anything i click play and nothing really happens.
Regards,
Tom, iMacros Support
Tom, iMacros Support
Re: Loop script until...
the script is not working. even though the string "Level: 88" appeared, the script continued, if anything it sped up. Which is kind of odd. I dont know what's wrong, i just copy and pasted the script you wrote, into a .js file and played it.
-322126384
Re: Loop script until...
It took me about 3 hours of searching but then it hit me. why not just use the SEARCH command. It has REGEXP. Here is a code i wrote:
the code clicks on the up arrow. then it searches for Level: 44-99. then it is passed to the TAG command which encorporates the FAIL_IF_FOUND event and looks in the html elements for "Level: (whichever number between 44-99 was found)".
This code is not tested yet so i'll be doing that now. i'll get back to you with the results. hopefully it works!
Code: Select all
TAG POS=1 TYPE=IMG ATTR=SRC:http://static.pokemonvortex.org/images/maps/arrows/arrowup.gif
SET !ERRORIGNORE YES
SEARCH SOURCE=REGEXP:"Level: ([4-9]{2})" EXTRACT=$1
SET !ERRORIGNORE NO
TAG POS=1 TYPE=P ATTR=TXT:Level:<SP>{{!EXTRACT}} CONTENT=EVENT:FAIL_IF_FOUND
This code is not tested yet so i'll be doing that now. i'll get back to you with the results. hopefully it works!
-322126384
Re: Loop script until...
i just tested the macro and it runs perfectly. I just caught 3 legendary pokemon! Good Luck Catching Pokemon!!
-322126384
Re: Loop script until...
your regex is wrong [4-9]{2} will match 44-49, 54-59, ..94-99
you need ([5-9][0-9]) which will match 50-99
you need ([5-9][0-9]) which will match 50-99